ctf/core.lua: Fix incorrect indentation
This commit is contained in:
parent
38c27736f6
commit
579d449ef4
1 changed files with 29 additions and 29 deletions
|
@ -1,43 +1,43 @@
|
||||||
-- Awaiting core support.
|
-- Awaiting core support.
|
||||||
local function __genOrderedIndex( t )
|
local function __genOrderedIndex( t )
|
||||||
local orderedIndex = {}
|
local orderedIndex = {}
|
||||||
for key in pairs(t) do
|
for key in pairs(t) do
|
||||||
table.insert( orderedIndex, key )
|
table.insert( orderedIndex, key )
|
||||||
end
|
end
|
||||||
table.sort( orderedIndex )
|
table.sort( orderedIndex )
|
||||||
return orderedIndex
|
return orderedIndex
|
||||||
end
|
end
|
||||||
|
|
||||||
local function orderedNext(t, state)
|
local function orderedNext(t, state)
|
||||||
-- Equivalent of the next function, but returns the keys in the alphabetic
|
-- 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
|
-- order. We use a temporary ordered key table that is stored in the
|
||||||
-- table being iterated.
|
-- table being iterated.
|
||||||
|
|
||||||
local key = nil
|
local key = nil
|
||||||
if state == nil then
|
if state == nil then
|
||||||
t.__orderedIndex = __genOrderedIndex( t )
|
t.__orderedIndex = __genOrderedIndex( t )
|
||||||
key = t.__orderedIndex[1]
|
key = t.__orderedIndex[1]
|
||||||
else
|
else
|
||||||
for i = 1,table.getn(t.__orderedIndex) do
|
for i = 1,table.getn(t.__orderedIndex) do
|
||||||
if t.__orderedIndex[i] == state then
|
if t.__orderedIndex[i] == state then
|
||||||
key = t.__orderedIndex[i+1]
|
key = t.__orderedIndex[i+1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if key then
|
if key then
|
||||||
return key, t[key]
|
return key, t[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- no more value to return, cleanup
|
-- no more value to return, cleanup
|
||||||
t.__orderedIndex = nil
|
t.__orderedIndex = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function orderedPairs(t)
|
function orderedPairs(t)
|
||||||
-- Equivalent of the pairs() function on tables. Allows to iterate
|
-- Equivalent of the pairs() function on tables. Allows to iterate
|
||||||
-- in order
|
-- in order
|
||||||
return orderedNext, t, nil
|
return orderedNext, t, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue