-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bump.lua: 619: attempt to index field 'rects' (a nil value) #35
Comments
Can you post an example of your code which causes this error to occur? |
Thanks for the quick reply! Yeah, I'm just trying to make a simple tiled based top down game where I can walk the player around the screen. I want to have objects and buildings that the player won't walk through, but will bump into. ` function love.load() objects= {} function love.draw() function love.update(dt) if player.move == true then end |
Hi there, the problem is that you wrote |
Oh wow, such a simple fix. Thanks for catching that! I re-read that a thousand times and still didn't see the mistake. |
As the title says, when I go to run this in LOVE 0.10.2 I get "bump.lua: 619: attempt to index field 'rects' (a nil value)." I have copied the function mentioned below. I am new to programming so I don't know how to fix this or work around it. Any help is appreciated!
function World:add(item, x,y,w,h)
local rect = self.rects[item] --this is line 619 and contains the "rects" referred to
if rect then
error('Item ' .. tostring(item) .. ' added to the world twice.')
end
assertIsRect(x,y,w,h)
self.rects[item] = {x=x,y=y,w=w,h=h}
local cl,ct,cw,ch = grid_toCellRect(self.cellSize, x,y,w,h)
for cy = ct, ct+ch-1 do
for cx = cl, cl+cw-1 do
addItemToCell(self, item, cx, cy)
end
end
return item
end
The text was updated successfully, but these errors were encountered: