diff --git a/mods/ctf/ctf/core.lua b/mods/ctf/ctf/core.lua index 6125b81..05a3747 100644 --- a/mods/ctf/ctf/core.lua +++ b/mods/ctf/ctf/core.lua @@ -1,43 +1,43 @@ -- Awaiting core support. local function __genOrderedIndex( t ) - local orderedIndex = {} - for key in pairs(t) do - table.insert( orderedIndex, key ) - end - table.sort( orderedIndex ) - return orderedIndex + local orderedIndex = {} + for key in pairs(t) do + table.insert( orderedIndex, key ) + end + table.sort( orderedIndex ) + return orderedIndex end local function orderedNext(t, state) - -- Equivalent of the next function, but returns the keys in the alphabetic - -- order. We use a temporary ordered key table that is stored in the - -- table being iterated. + -- Equivalent of the next function, but returns the keys in the alphabetic + -- order. We use a temporary ordered key table that is stored in the + -- table being iterated. - local key = nil - if state == nil then - t.__orderedIndex = __genOrderedIndex( t ) - key = t.__orderedIndex[1] - else - for i = 1,table.getn(t.__orderedIndex) do - if t.__orderedIndex[i] == state then - key = t.__orderedIndex[i+1] - end - end - end + local key = nil + if state == nil then + t.__orderedIndex = __genOrderedIndex( t ) + key = t.__orderedIndex[1] + else + for i = 1,table.getn(t.__orderedIndex) do + if t.__orderedIndex[i] == state then + key = t.__orderedIndex[i+1] + end + end + end - if key then - return key, t[key] - end + if key then + return key, t[key] + end - -- no more value to return, cleanup - t.__orderedIndex = nil - return + -- no more value to return, cleanup + t.__orderedIndex = nil + return end function orderedPairs(t) - -- Equivalent of the pairs() function on tables. Allows to iterate - -- in order - return orderedNext, t, nil + -- Equivalent of the pairs() function on tables. Allows to iterate + -- in order + return orderedNext, t, nil end