Please help a Lua newb?
Posted: Sun Jan 03, 2010 8:25 pm
So, just got started with Love, (and programming in general) so I don't know all that much about how Lua works. I'm experimenting with tables, and have run into a problem when trying to repeat something for each argument in a table. I'm trying to replicate what I have done in part A with part B, but make it a repeating function(and 50 pixels lower), rather than writing each line out. When I run this, I get the error "main.lua:19: bad argument #1 to 'print' (string expected, got nil)"
Something tells me this is a simple fix, but I can't find it. Can anyone help? Thanks in advance!
Something tells me this is a simple fix, but I can't find it. Can anyone help? Thanks in advance!
Code: Select all
a = {1,1,2,3,5,8,13}
x = 0
function love.draw()
--***part A:***
love.graphics.print(a[1], 100, 100)
love.graphics.print(a[2], 110, 100)
love.graphics.print(a[3], 120, 100)
love.graphics.print(a[4], 130, 100)
love.graphics.print(a[5], 140, 100)
love.graphics.print(a[6], 150, 100)
love.graphics.print(a[7], 160, 100)
--***part B:***
repeat
x = x+1
love.graphics.print(a[x], (100+(x*10-10)), 150)
until x == 7
end