Page 1 of 1

Destroying props

Posted: Sat Nov 24, 2012 1:24 am
by Hoodlum
I created a neat "now you see it, now you don't" effect where I press a button, and a secret wall covers the statue, seconds later the statue is mysteriously gone.

It works like a charm, but about 5 seconds after the secret door reveals that it is gone, the program crashes and I'm returned to the editor with this error: "attempt to index global "dragonstatue" (a nil value) X"

I only get the error after I've tested the event.

The destroy script is:

Code: Select all

--
function destroydragon()

	dragonstatue:destroy()
	end

Anyone else having either the same trouble or any solution?

Re: Destroying props

Posted: Sat Nov 24, 2012 1:28 am
by Phitt
I assume you have a timer running to destroy the statue. You have to deactivate the timer or else the function will activate again, which causes a crash since the 'dragonstatue' entity doesn't exist anymore (you just destroyed it after all).

Re: Destroying props

Posted: Sat Nov 24, 2012 1:34 am
by Hoodlum
Ah! I assumed it had something to do with the function repeating itself...
Wouldn't guess it was actually the timer being the culprit. :ugeek:

The magical act is now performing as it should. Buy tickets. Special price for you.

Thanks for the quick reply!

Re: Destroying props

Posted: Sat Nov 24, 2012 2:17 am
by Komag
it's a good habit to pretty much always set your timers to deactivate