alestane icon

Dictionary loader (repeated resume)

alestane | PRO | 01/17/14 03:57:38 PM UTC | 0 ⭐ | 324 👁️ | Never ⏰ | []
Lua |

530 B

|

None

|

0 👍

/

0 👎

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