Pattern Matching Question
Posted: Mon Jan 25, 2010 8:34 pm
Hi, guys.
I have a function that needs to load a bunch of values from lines in a file. Here's what I have so far:
Basically, this loads a table of rows and columns (to be used in a simplistic tile map engine).
The problem is the third from the last line, which loads the actual data into the table index. Everything else works perfectly. I know that if I have fourteen lines with 25 numbers each in the text file, I'll get a table filled with 14*25 values. If I simply susbstitute the "word" with a "1," the tile with the index of "1" loads.
So my question is... since I can count the number of tile references in my file, what do I need to change to make it take the actual reference and insert it into the file?
I have a function that needs to load a bunch of values from lines in a file. Here's what I have so far:
Code: Select all
if filepos=="tiles" then
row=row+1
column=0
tilelist[row]={}
for word in string.gfind(line, "[%d]+") do
column=column+1
tilelist[row][column]=word
end
end
The problem is the third from the last line, which loads the actual data into the table index. Everything else works perfectly. I know that if I have fourteen lines with 25 numbers each in the text file, I'll get a table filled with 14*25 values. If I simply susbstitute the "word" with a "1," the tile with the index of "1" loads.
So my question is... since I can count the number of tile references in my file, what do I need to change to make it take the actual reference and insert it into the file?