I started playing around with the networking in Leadwerks and found that I needed enums. So I wrote a function that will allow you to enumerate a table.
function enumerate(array,indexstart) -- indexstart is optional
if array == nil then return nil end
local array2 = {}
local count = tonumber(indexstart) ~= nil and tonumber(indexstart) or 0
for key,value in pairs(array) do
array2[value] = count
count = count + 1
end
return array2
end
This will take an array of strings and output a named table array.
enum_netchat = enumerate({
"client",
"team",
"all",
"servertoclient",
"servertoteam",
"servertoall"
},1)
This is the simplest way to make an enum
enum_netchat.all