Hey, I am creating a sandbox game using love physics and other libaries (Light vs shadow engine v2 and videolib). I've create a map and when I place a "block", it create a new physic body but when I want to destroy one, it say me " main.lua:238: attempt to index a nil value".
I check all my code but I don't find the bug ...
(Sorry if my english is very poor, i'm french)
Here my game in .love
Destroy body with Löve2D physics
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Destroy body with Löve2D physics
- Attachments
-
- UnviPlanet.love
- (5.08 MiB) Downloaded 169 times
function love.load() end
function love.update(dt) end
function love.draw() end
function love.update(dt) end
function love.draw() end
Re: Destroy body with Löve2D physics
Here a screenshot of the game :
function love.load() end
function love.update(dt) end
function love.draw() end
function love.update(dt) end
function love.draw() end
- ArchAngel075
- Party member
- Posts: 319
- Joined: Mon Jun 24, 2013 5:16 am
Re: Destroy body with Löve2D physics
been modifying the map.lua and main.lua
so many changes to make it work as expected.
I was able to make adding work, removing doesn't exactly work physics wise (but does graphically)
One major issue is you are working on globals 'stone' and 'dirt'
when you make the map, stone and dirt globals are overwritten each time a tile is made, this will result in stone and dirt globals being allllways the last overwrite.
is this intended?
also you use stone.x, stone.y which neither field exists.
so many changes to make it work as expected.
I was able to make adding work, removing doesn't exactly work physics wise (but does graphically)
One major issue is you are working on globals 'stone' and 'dirt'
when you make the map, stone and dirt globals are overwritten each time a tile is made, this will result in stone and dirt globals being allllways the last overwrite.
is this intended?
also you use stone.x, stone.y which neither field exists.
Re: Destroy body with Löve2D physics
Hey !
What should I do to no work on globals stone and dirt ?
I didn't thought that it was overwritte each time a tile is made, I am fixing this.
I am deleting all the stone.x an stone.y
And, can I have the code you made ? Just to see
Thank you ! And I'm new in Love2D So I am not very good :/
What should I do to no work on globals stone and dirt ?
I didn't thought that it was overwritte each time a tile is made, I am fixing this.
I am deleting all the stone.x an stone.y
And, can I have the code you made ? Just to see
Thank you ! And I'm new in Love2D So I am not very good :/
function love.load() end
function love.update(dt) end
function love.draw() end
function love.update(dt) end
function love.draw() end
- ArchAngel075
- Party member
- Posts: 319
- Joined: Mon Jun 24, 2013 5:16 am
Re: Destroy body with Löve2D physics
err, my method isnt well made at the moment but sure ill zip up the edited files sofar.
KEY : Search the word 'ADDED' for any additions and changes i made if you don't have code comparers. To answer immediately your questions too :
1. Stone and Dirt globals are overwritten - in my edits i made a new table map_items
there is map_items.stone, map_items.dirt
I store each tile(?) in its own location by x,y ()
I kept it to overwrite global, i just use the line 'map_items.stone[x][y] = stone' to store the changes. I believe that should work.
I just returned to Love2D myself randomly nd decided to help, so apologies if my fixes are actually terrible.
good luck!
KEY : Search the word 'ADDED' for any additions and changes i made if you don't have code comparers. To answer immediately your questions too :
1. Stone and Dirt globals are overwritten - in my edits i made a new table map_items
there is map_items.stone, map_items.dirt
I store each tile(?) in its own location by x,y ()
I kept it to overwrite global, i just use the line 'map_items.stone[x][y] = stone' to store the changes. I believe that should work.
I just returned to Love2D myself randomly nd decided to help, so apologies if my fixes are actually terrible.
good luck!
Re: Destroy body with Löve2D physics
Hey ! Really, thank you ! I am working on your code now
function love.load() end
function love.update(dt) end
function love.draw() end
function love.update(dt) end
function love.draw() end
Who is online
Users browsing this forum: Bing [Bot] and 2 guests