Advertisement
alestane

Dictionary loader (repeated resume)

Jan 17th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local path = system.pathForFile("wordlist.txt",system.ResourceDirectory)
  2.  
  3. local function dictionary(path, trigger)
  4.     local dictTable = {}
  5.     coroutine.yield(dictTable)
  6.     local lineCounter = 100
  7.     for line in io.lines(path) do
  8.         dictTable[line] = true
  9.         print(tostring(line))
  10.         lineCounter = lineCounter - 1
  11.         if lineCounter <= 0 then
  12.             lineCounter = lineCounter + 100
  13.             coroutine.yield()
  14.         end
  15.     end
  16.     timer.cancel(trigger)
  17. end
  18.  
  19. local loader = coroutine.wrap(dictionary)
  20.  
  21. return loader(path, timer.performWithDelay(1, loader, 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement