Advertisement
alestane

Dictionary loader (pre-yield)

Jan 17th, 2014
168
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)
  4.     local dictTable = {}
  5.     coroutine.yield(dictTable)
  6.     for line in io.lines(path) do
  7.         dictTable[line] = true
  8.         print(tostring(line))
  9.     end
  10.     return dictTable
  11. end
  12.  
  13. local loader = coroutine.wrap(dictionary)
  14.  
  15. return loader(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement