Page 2 of 2

Re: windfield/init.lua:36: attempt to call method 'collisionClear' (a nil value)

Posted: Sat May 11, 2019 10:52 pm
by pgimeno
DjSapsan wrote: Sat May 11, 2019 6:15 pm Well, idk how it works, but i fixed.
I had this line:

Code: Select all

 self.world:setCallbacks(beginContact, endContact, preSolve, postSolve)
That line was at few lines after original problem:

Code: Select all

self.world = wf.newWorld(0, 0, true)
Somehow Lua interpreted "setCallbacks" at the same time as creating new world. Last line that debugger has reach was creating world! I was not expected that line after error can cause problems O_o
I sounds stupid but i cant explain this...
No one could know that you had that line, because you didn't show your code. Next time you ask for help, please provide your code, because otherwise there's no way to help.

Re: windfield/init.lua:36: attempt to call method 'collisionClear' (a nil value)

Posted: Sun May 12, 2019 7:37 pm
by DjSapsan
[/quote]
No one could know that you had that line, because you didn't show your code. Next time you ask for help, please provide your code, because otherwise there's no way to help.
[/quote]

Well i was wrong one more time.
Line:

Code: Select all

world:setCallbacks(beginContact, endContact, preSolve, postSolve)
doesnt cause any error. I guess its was mess with variables. I had variable 'world' and my class was called 'World'. Maybe that names intersected with variables inside Winfield lib.

Re: windfield/init.lua:36: attempt to call method 'collisionClear' (a nil value)

Posted: Sat May 25, 2019 8:59 am
by TheHUG
That's interesting, I thought the whole point of
`return wf`
at the end of init.lua was to encapsulate the namespace so you only have to deal with the `wf` table.

`
wf = require("windfield/windfield")
World = "bbbuh"
function love.load()
wf.newWorld(0, 0, false)
end
`
crashes, unless line 2 is commented out, then it runs fine. I wouldn't have realised this if you hadn't pointed it out, thanks.

The actual windfield repo seems to be abandonded. If you want to make sure this doesn't happen again just put declare World to be `local` in your windfield installation. or...

I'm going to quickly plug my own library, a shameless windfield ripoff which I personally prefer (https://github.com/HDictus/breezefield). I'll go through it to make sure I haven't made the same mistake and left some global variables lying around.

Breezefield doesn't currently support windfield's 'collision class' system (and I haven't yet implemented a different one), but other than that should be really easy to swap with windfield ( just change `wf=require('windfield')` to `wf.require('breezefield')`, the rest should be the same. If you do try this and encounter problems, let me know on github!)