Skip to content

Allow custom enum declaration inside the script #368

@Aldrin-John-Olaer-Manalansan

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions