Page 1 of 1

Fixture destroy check

Posted: Tue Aug 05, 2014 8:08 am
by elkiwydev
Hi everyone,
I have a little problem.. I'm stuck in the error "Attempt to use a destroyed fixture" and I can't find a solution..
How do I check if a fixture is destroyed or not? I tried with "a==nil" (a is the fixture) but is not nil,is just destroyed..
Also every method I try to apply to the fixture like a:getBody() return the error..
I want to do an if statement like

Code: Select all

if *the fixture is destroyed* then
    --do nothing
else
   --do the work with the fixture
end
Please help :cry:

Re: Fixture destroy check

Posted: Wed Aug 06, 2014 1:26 pm
by OmarShehata
This is generally a code design flaw.

Why is it that your code is trying to use a destroyed fixture anyway? If you're keeping them in an array, make sure you remove the destroyed ones, or mark them as destroyed in a table until they get removed.

Alternatively, you can try running a test through pcall, to catch the error, but you should really redesign your code to avoid this situation in the first place.

If you can give more info on how things are set up we can try to come up with more specific solutions :)