Skip to content

Allow custom enum declaration inside the script #368

Open

Description

Custom Enums are super useful especially when trying to enumerate something that isn't included by default in SB or SBL.

Currently, SB provides built-in enums, which can be found in the enums.txt file. While I think it's also possible for users to {$include} a file that contains custom user-defined enums.

But SB doesn't allow users to define script-specific enums. So users inconveniently use constants to do so:

{$CLEO}
nop

const
    ENUMNAME1_THISFIELD1 = 0
    ENUMNAME1_THISFIELD2 = 1
    ENUMNAME1_THISFIELD3 = 2
    ENUMNAME1_THISFIELD4 = 3
    ENUMNAME1_THISFIELD5 = 4

    ENUMNAME2_THATFIELD1 = 0
    ENUMNAME2_THATFIELD2 = 1
    ENUMNAME2_THATFIELD3 = 2
    ENUMNAME2_THATFIELD4 = 33
    ENUMNAME2_THATFIELD5 = 34
end

// ... script section
31@ = ENUMNAME2_THATFIELD5
30@ = ENUMNAME1_THISFIELD3

It would be very convenient if we could create our custom enum inside the script:

{$CLEO}
nop

enum EnumName1
    ThisField1
    ThisField2
    ThisField3
    ThisField4
    ThisField5
end

enum EnumName2
    ThatField1
    ThatField2
    ThatField3
    ThatField4 = 33
    ThatField5
end

// ... script section
31@ = EnumName2.ThatField5
30@ = EnumName1.ThisField3

Activity

  1. added
    type:feature
    priority:p3
    on Apr 18, 2025
  2. added this to the Enum Support milestone on Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:p3scope:compilertype:feature

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions