I was messing around with this and thought I'd share in case someone else can get use of it and doesn't want to do it the long way around.
To use it place a pit and pressure_plate_hidden on the same space, hook the activate of the pressure_plate_hidden to the script to call pitTimer
It will then create a timer with an id linked to the pressure plate and link that timer back to the script (called "script_entity_fleet" here) which causes the pit to open after the first interval and close after the second. It will then destroy the timer and be set ready for the party when they come around again.
I'm using this for a room where the party has to keep moving and 0.5 seconds is tough as any mistake puts you down a hole and you can't turn to face a new direction. Other uses are to chance the timers interval after you open the pit so that you can make it close slower than it opened.
Hope someone finds it useful. Enjoy
function pitTimer(object)
local timerID = "fleet_timer_"..object.id
if findEntity( timerID ) == nil then
spawn("timer", object.level, object.x, object.y, object.facing, timerID )
findEntity( timerID ):setTimerInterval(0.5)
findEntity( timerID ):addConnector("activate", "script_entity_fleet", "togglePit")
findEntity( timerID ):activate()
end
end
function togglePit( timer )
for iter in entitiesAt(timer.level,timer.x,timer.y) do
if iter.name == "prison_pit" then
if iter:isOpen() then
iter:close()
timer:destroy()
else
iter:open()
end
end
end
end