Page 1 of 1
Pressure plate script keeps crashing
Posted: Fri Oct 05, 2012 8:54 pm
by StingrayNine
Hi guys, i tried to make a pressureplate appear when stepping over a hidden one and removing it once the created one has been stepped off.
The code i have looks like this:
Code: Select all
function createPlate()
spawn("temple_pressure_plate", 1, 12, 0, 0, "triggerPlate")
triggerPlate:addConnector("activate", "plateDoor", "open")
triggerPlate:addConnector("deactivate", "plater1", "removePlate")
end
function removePlate()
triggerPlate:destroy()
end
It works splendidly until i step off the created plate because it crashes the editor/game when i do...
Do i have to create another hidden plate or something to trigger the removePlate()-function or am i doing something seriously wrong?
Re: Pressure plate script keeps crashing
Posted: Fri Oct 05, 2012 8:55 pm
by Komag
it may need a very short delay - connect to a timer which will destroy it after 0.1 sec
Re: Pressure plate script keeps crashing
Posted: Fri Oct 05, 2012 9:15 pm
by StingrayNine
Komag wrote:it may need a very short delay - connect to a timer which will destroy it after 0.1 sec
I'll be honest and tell you i'm still trying to figure out how to properly use timers and counters in the editor. Do you have a snippet for the timer?
The thing which comes to my mind is making a timer, hooking it to a counter making it trigger the destroy after one second. Which does not sound efficient at all to my eyes/ears.
Edit: Fixed it with a slight delay like you said. No idea why it would crash if you remove it the instant you step off the plate as i would rather not use a timer and counter aswell. But i guess i can't argue with results.
Solution:
Code: Select all
Create timer with 0.2 second interval,
Create counter with 1 tick,
Link timer with counter,
Link counter with script using
Code: Select all
function delay()
plateTimer:activate()
end
Re: Pressure plate script keeps crashing
Posted: Fri Oct 05, 2012 10:15 pm
by Komag
just a timer, no counter. have the step off script just trigger the timer, not destroy the plate. Then have the timer set for only 0.1 seconds, and have it link to a third function that finally destroys the plate.
having plates appear and disappear might seem a little odd though
Re: Pressure plate script keeps crashing
Posted: Fri Oct 05, 2012 10:19 pm
by StingrayNine
Komag wrote:just a timer, no counter. have the step off script just trigger the timer, not destroy the plate. Then have the timer set for only 0.1 seconds, and have it link to a third function that finally destroys the plate.
having plates appear and disappear might seem a little odd though
The plate is just a placeholder for another invisible plate right now. And that was atleast one step smarter than what i had set up. Thanks for the help.