about summary refs log tree commit diff stats
path: root/lua/enum.lua
blob: 60c657e09730920b73c1d5d25c9542aae3732d21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- because sometimes you need an enum

function enum(tbl)
    local length = #tbl
    for i = 1, length do
        local v = tbl[i]
        tbl[v] = i
    end
    return tbl
end

local Game_Status = enum {
	"MENU",
	"PLAY",
	"QUIT"
}

print(Game_Status.MENU) -- 1
print(Game_Status.PLAY) -- 2, .etc