help with pressure plate script

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
roachburn
Posts: 17
Joined: Wed Sep 19, 2012 11:22 am

help with pressure plate script

Post by roachburn »

So I am trying to use a script to open a door when 2 pressure plates are activated. I managed to use the script below to accomplish this, however it only works once. I want it so that if I remove the rocks from the pressure plate the door closes and if they are reaplied the door opens again. any help?
SpoilerShow
counter = 2

function activate()
counter = counter - 1
checkValue()
end

function deactivate()
counter = counter + 1
checkValue()
end

function checkValue()
if counter == 0 then
pressuredoor:open()
else
pressuredoor:close()
end
end
User avatar
Montis
Posts: 340
Joined: Sun Apr 15, 2012 1:25 am
Location: Grimrock II 2nd playthrough (hard/oldschool)

Re: help with pressure plate script

Post by Montis »

have you connected each of the pressure plates twice to the script_entity, once with event activate, action activate and once with event deactivate, action deactivate?

you also probably don't even need a script for this as there is a counter-entity that you could use. set it to initial value 2 and connect it to the door on the any event with action toggle. then connect the pressure plates twice to the counter once with event activate, action decrement and once with event deactivate, action increment.
can't test right now but that should work.
When destiny calls, the chosen have no choice.

My completed dungeon (LoG1): Hypercube
roachburn
Posts: 17
Joined: Wed Sep 19, 2012 11:22 am

Re: help with pressure plate script

Post by roachburn »

That did it! Thanks a bunch. I was missing this in a bunch of other scripts and that fixes them all. Thanks again!
Post Reply