I have an issue with a project of mine(i know, i make a lot of projects, it's because i want to improve my abilties the quickest possible) it's a platformer, and i have a problem very strange. I have a lua table, and i try to add a value to this table by a function but it doesn't work, each time i tell to the computer to print the length of the table, it always return zero. Why.
there's the buggy code:
collision.lua
Code: Select all
function newCollisionBox(x, y, id, what_x, what_y, skin) -- suuposed to create a collision object.
blocs = {} -- this is the table i want to add a value in
blocs[id] = {} -- this is the value i add
blocs[id].x = x
blocs[id].y = y
blocs[id].sprite = love.graphics.newImage('assets/tiles/'..skin..'.png')
end
Code: Select all
function love.draw()
love.graphics.print(loop, 0, 0)-- values
love.graphics.print(up .. down .. left .. right, 0, 10)
love.graphics.print(#blocs, 0, 20) -- here i want to verify my code, but it always return nil
playerdraw()
end