This is a module I’ve made that allows custom enums.
I call it custom enum.This is similar and based on C#'s enum.
What does this do?
It’s just a custom enum value, with features like comparing enums. This is more powerful than a table.
How do I create one?
Simple, just do something like this
local seasons = customenum { "Spring", "Summer", "Autumn", "Winter" };
print(seasons.Spring);
print(seasons.Spring.ToInt32());
Spring
0
note that it’s zero based index instead of one based index
Alternatively you can do somehting like this
local options = customenum
{
option1 = 0b0001,
option2 = 0b0010,
option3 = 0b0100,
option4 = 0b1000,
};
Similar to C#
public enum options
{
option1 = 0b0001,
option2 = 0b0010,
option3 = 0b0100,
option4 = 0b1000,
}
You can set it to any integer from -2 147 483 648 to 2 147 483 647
Please note it’ll throw an error if the character has any other characters other than letters, numbers and underscores (_
) or if it begins with a number or it’s a reserved keyword.
local error = customenum { '1this', 'will!', 'throw an', 'error!', 'if' }
will throw an error
More parts will be documented later.
Where do I get this?
You can download this via GitHub or you can get it here:
1.0.0:
- File (5·74 KiB)
- Released: 14 May 2020, 01.05.05 (CET)
- BSD 2-clause licence