Pressure plate script keeps crashing

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
StingrayNine
Posts: 4
Joined: Fri Oct 05, 2012 5:28 pm

Pressure plate script keeps crashing

Post 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?
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Pressure plate script keeps crashing

Post by Komag »

it may need a very short delay - connect to a timer which will destroy it after 0.1 sec
Finished Dungeons - complete mods to play
StingrayNine
Posts: 4
Joined: Fri Oct 05, 2012 5:28 pm

Re: Pressure plate script keeps crashing

Post 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
Last edited by StingrayNine on Fri Oct 05, 2012 10:18 pm, edited 1 time in total.
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Pressure plate script keeps crashing

Post 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
Finished Dungeons - complete mods to play
StingrayNine
Posts: 4
Joined: Fri Oct 05, 2012 5:28 pm

Re: Pressure plate script keeps crashing

Post 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.
Post Reply