Ok I had a go at this myself... did a short 5 pit sequence, with at most 2 pits open at a time (to allow for walking between them) and it seemed to work pretty well.
- Create a series of pits and call them
sequence_pit_01,
sequence_pit_02,
sequence_pit_03... etc. (for the purpose of this version of the script we need 5 pits)
- note: it will help understanding the script if you name the pits in the order in which they are to be closed.
- Make sure each pit is a trapdoor!
- Add a timer, name it
pit_sequence_timer and set the interval as the length of time between one pit and the next closing.
- Add a script entity, call it
pit_sequence and paste in the following script:
Code: Select all
time = 0
function openAllPits()
for i in allEntities(party.level) do
if i.id:sub(1,13) == "sequence_pit_" then
i:open()
end
end
end
function startSequence()
openAllPits()
pit_sequence_timer:deactivate()
time = 0
pit_sequence_timer:activate()
end
function tick()
if
time == 1
then
sequence_pit_01:close()
elseif
time == 2
then
sequence_pit_02:close()
elseif
time == 3 then
sequence_pit_01:open()
sequence_pit_03:close()
elseif
time == 4 then
sequence_pit_02:open()
sequence_pit_04:close()
elseif
time == 5 then
sequence_pit_03:open()
sequence_pit_05:close()
elseif
time == 6 then
sequence_pit_04:open()
elseif
time == 7 then
sequence_pit_05:open()
pit_sequence_timer:deactivate()
end
time = time + 1
end
CONNECTIONS:
- connect the button to the script with the action
startSequence
- connect the timer to the script with the action
tick
Note: This works for 5 pits, if you want to add more pits it is no problem just add more blocks of elseif time == x statements and refer to the relevant pit names like so:
Code: Select all
elseif
time == 6 then
sequence_pit_04:open()
sequence_pit_06:close()
script notes -
* when the button is pushed it first runs a function to open all pits in the level called "sequence_pit_XX"... this is to allow for the situation where the player keeps pressing the button once the sequence has started and forces a reset.
* The initial deactivate of the timer in the start function may not be necessary, but does allow scope for adjusting the interval in the script by first stopping the timer and restarting it. just add a setTimerInterval() command in between.