-- sequence1:
Make a switch, lever or hidden_pressure_plate what ever to your liking (mine is called lever_sound)
--sequence2:
Step 1: link lever_sound to a lua script "soundStart" with the following code WITHOUT time delay
Code: Select all
function startSprintLoop()
if lever_sound:getLeverState() == "activated"
then teleToggle:toggle() -- this is just to toggle a teleporter thats not used in the game.
playSound("timeloop") -- play the 12 sec wave file
timer_tele:deactivate() -- needed to prevent loop, crashing the game
loopTimer:deactivate() -- needed to prevent loop, crashing the game
end
end
Code: Select all
function leverSoundStop()
if lever_sound:getLeverState() == "activated"
then lever_sound:destroy() -- destroys the lever, switch or pressure plate to your liking, instandly. so it prevents being activated again for the next 12 seconds --as timer_tele has a delay for 12 seconds
timerDestroy:deactivate() --needed to prevent loop, crashing the game
end
end
Sequence3:
timer_tele is linked to another lua script ( that triggers after the 12 seconds as above stats) with the following code:
Code: Select all
spawnLeverloop()
spawn("lever", 11, 15, 5, 2, "lever_sound") --spawns the lever back where it was destoyed in sequence 1, step 2
lever_sound:addConnector("activate","loopTimer","activate") -- connects that new spawned lever to another timer (loopTimer)
timerDestroy:deactivate() --needed to prevent loop, crashing the game
timer_tele:deactivate() --needed to prevent loop, crashing the game
loopTimer:deactivate() --needed to prevent loop, crashing the game
end
step 1:
Pressing the new spawned lever_sound trigger will run another timer called "loopTimer" with a 0.01 sec delay/interval
step 2: Timer "looptimer" is linked to a script "soundStart2" with following code:
Code: Select all
function startSprintLoop2()
if lever_sound:getLeverState() == "activated"
then teleToggle:toggle()
playSound("timeloop")
timer_tele:activate() -- a tele in game that be deactivated after 12 seconds by ]"timer_tele"
loopTimer:deactivate() stops timer to prevent crashing the game
end
end
step 3 "timerDestroy" is connected to the luascript: "stopSound" with the following code:
Code: Select all
function leverSoundStop()
if lever_sound:getLeverState() == "activated"
then lever_sound:destroy() -- destroys the lever again.
timerDestroy:deactivate() --needed to prevent loop, crashing the game
end
end
I've used a lever in this case but it works with a hidden_pressure_plate, etc as well.
Video link: