First time coding in lua. (not much experience outside of lua either)
Created a table/array (Apparently there's no difference in lua?)
Use a while loop to go through the values of said table and compare them to a value. If it matches blah blah irrelevant.
What I need help with is properly using a for loop in lua.
I
could not understand the documentation I found on google so hopefully
someone here can either explain it or post the same code using a for
loop and I'll figure it out from there.
tl dr: How to for loop in lua?
Bonus question: Does it matter if I use a while loop? This particular function is called over and over if that matters.
//This is the two important parts, map is declared in a different function but I left it out because its irrelevant, map is a global variable.
map = { {0, 1, 0, 1, 0 },
{0, 0, 1, 0, 0 }
}
mapL = 5
mapW = 2
function love.draw()
i=0
j=0
while i<mapL do
while j<mapW do
if map[j+1][i+1] == 0 then
love.graphics.rectangle('fill', i*32, j*32, 32, 32)
end
j=j+1
end
i = i+1
j = 0
end
love.graphics.draw(image, player.act_x, player.act_y)
end