I need help to create a sequence of trapdoors so that only one is open at a time and the group has to jump at a time to avoid falling rapidly. I've tried and I can´t do it using timers
thanks again
trap door sequence
Re: trap door sequence
The following post by Antti may help with what you are trying to do
viewtopic.php?f=14&t=3213&hilit=tick
He describes using a timer that calls a function every interval and depending on the value it does something different... could be used to create a sequence puzzle with pits opening and closing.
viewtopic.php?f=14&t=3213&hilit=tick
He describes using a timer that calls a function every interval and depending on the value it does something different... could be used to create a sequence puzzle with pits opening and closing.
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: trap door sequence
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:
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:
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.
- 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
- 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()
* 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.
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: trap door sequence
Just thinking, It may be possible to adjust the timer based on the number of attempts the player has... so each time he falls down a pit, a pad triggers that increases the interval slightly... making the puzzle easier with each failure.Grimwold wrote: * 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.
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: trap door sequence
Nice adaptation! I used it before to set up a sequence of teleporters, very fun!
Finished Dungeons - complete mods to play
-
- Posts: 17
- Joined: Sat Sep 15, 2012 1:00 am
Re: trap door sequence
WOW, it works. thanks