Dictionary loader (repeated resume)
local path = system.pathForFile("wordlist.txt",system.ResourceDirectory)
local function dictionary(path, trigger)
local dictTable = {}
coroutine.yield(dictTable)
local lineCounter = 100
for line in io.lines(path) do
dictTable[line] = true
print(tostring(line))
lineCounter = lineCounter - 1
if lineCounter <= 0 then
lineCounter = lineCounter + 100
coroutine.yield()
end
end
timer.cancel(trigger)
end
local loader = coroutine.wrap(dictionary)
return loader(path, timer.performWithDelay(1, loader, 0))
Comments