I’m making a word game where I load a list of words stored in a txt file into a table so I can then search the list for a specific word. This worked fine in flash and the list which is 1.9mb loaded in seconds and I was able to search the list in no time as well. In the simulator it takes about a minute or 30s to load the list and each time I search the list it takes about a minute as well.
I am loading the list into a table and checking the table for the word using the following function:
–Check word against list
local checkWord = function(wordToCheck)
for _,v in pairs(wordList) do
if v == wordToCheck then
return true
end
end
return false
end
here is the load function:
–Load word list into array
local path = system.pathForFile( “wordlist.txt”, system.ResourceDirectory )
for line in io.lines(path) do
table.insert(wordList,line)
end
Is there a better way to do this to cut down on the time it takes? [import]uid: 3018 topic_id: 1215 reply_id: 301215[/import]
