Enums or constants in AngelScript

372 views Asked by At

In other programming languages I can use static class methods or enums to encapsulate constants:

enum Command {
    command_1 = "0x00001",
    command_2 = "0x00002",
    command_2 = "0x00003"
} 

or

class Command  {
    static command_1 = "0x00001"
    static command_2 = "0x00002"
    static command_3 = "0x00003"    
}

How is this solved in AngelScript? As far as I know there are neither enums (with non-integer values) nor static class methods.

2

There are 2 answers

0
arie On

You can use namespace:

namespace consts_values
{
    const string a = "aaa";
    const string b = "bbb";
}
0
ThomasZ On

In angelscript you can define enums as well. You also can assign integer constants to the enumerations. E.g.:

enum lock_state
{
    locked = 0,
    open = 1
}