For loop bug; prints all values with each index
Posted: Thu May 21, 2015 5:31 am
Not good at making subject titles, but here's the problem: I'm trying to pass a .txt file and parse it. The only thing though is that I want to print it to the screen. All goes well and dandy, but for some reason (probably obvious) it prints the first line of the file, then it proceeds to the first and second... straight across the string.
Example output:
Of this .txt file:
I feel like I'm missing some simple knowledge of lua/logic, but I can't find a answer to it. Here's the for loop:
Thanks a bunch,
- redsled
Example output:
Code: Select all
1 0 0 0
1 0 0 0 1 0 0 0 2
1 0 0 0 1 0 0 0 2 1 0 0 0
Code: Select all
1,0,0,0,
1,0,0,0,2,
1,0,0,0,
Code: Select all
y = 0
x = 0
for i=1,#num do
local v = num[i]
love.graphics.print(v, x, y)
x = x + 15
if v == "" then
y = y + 15
x = 0
end
end
- redsled