local function makeEnum(enumtable) if enumtable == nil or type(enumtable) ~= "table" then return nil end enumtable.__index = enumtable enumtable.__newindex = function() print("can not modify enum") end local e = {} setmetatable(e, enumtable) return e end local function main() local mode = makeEnum({ SinglePlayer = 1, TwoPlayers= 2, ThreePlayers= 3, FourPlayers= 4, PVCom= 5, }) mode.SinglePlayer = 2 print(mode.SinglePlayer) end main()