Anonymous

Module:FunList/Iterators: Difference between revisions

From Melvor Idle
no edit summary
No edit summary
No edit summary
Line 22: Line 22:
-- Hooks the moveNext function into the Lua 'pairs' function
-- Hooks the moveNext function into the Lua 'pairs' function
function Enumerator:overridePairs()
function Enumerator:overridePairs()
mw.log('overriding pairs()')
self.index = nil
self.current = nil
local function iterator(t, k)
local function iterator(t, k)
if self:moveNext() == true then
if self:moveNext() == true then
Line 29: Line 32:
end
end
self.index = nil
self.current = nil
return iterator, self, nil
return iterator, self, nil
end
end
Line 48: Line 49:
function TableEnumerator:moveNext()
function TableEnumerator:moveNext()
mw.log('calling override with')
mw.log('calling override with')
mw.log('key: ' .. self.index)
mw.log('key: ' .. tostring(self.index))
mw.log('val: ' .. self.current)
mw.log('val: ' .. tostring(self.current))
-- Grab the next index for the internal table.
-- Grab the next index for the internal table.
local key = self.index
local key = self.index
2,875

edits