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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

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

Post 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.
DjSapsan
Prole
Posts: 10
Joined: Tue Apr 30, 2019 3:57 pm

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

Post 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.
TheHUG
Citizen
Posts: 61
Joined: Sun Apr 01, 2018 4:21 pm

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

Post 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!)
Post Reply

Who is online

Users browsing this forum: No registered users and 83 guests