Page 1 of 1
Question about sound loops.
Posted: Sat Apr 04, 2015 3:09 pm
by trancelistic
Hey all,
I was wondering. If i made a timepuzzle,
Let say hit a switch and you got 8 seconds to enter a teleporter.
I want to play a tensed little timer sound for its duration. ( I've made that wave and it works)
But hitting the switch multible times causes the *.wav file to played over and over. How to prevent this? ( Like if i pressed the switch 8 times within the 8 sec timer, then that *.wav is played 8 x at the same time, I do not want this"
Any advise on this? That would be great.
Ps: Vink: "Activate only onces" doesn't work because if they fail on the first attempt to find the teleporter then they are stuck in the game. They should be able to press the switch again and then the 8 sec *.wave also plays again.
Re: Question about sound loops.
Posted: Sat Apr 04, 2015 3:22 pm
by THOM
Depending on your script it's not only the sample, that is started over and over again but also the timeslot itself. So if a player hits the button again, he can enlonging the time as long has he/she wants...
I think you have to add a variable - a counter or in your script a local a = 0.
On hitting the button there must be a query of the value of the counter/variable, after starting the time the counter/variable must be incremented and as long as it is = 1 the button doesn't work anymore. At the end of the sample/time, the value must be set back to zero.
Re: Question about sound loops.
Posted: Sun Apr 05, 2015 5:10 am
by Isaac
Place and add a connection to the timerSound function. The player can press the as many times as they wish, but the script ignores it until the time is up.
Code: Select all
duration = 8 --seconds
ignore = false
function timerSound()
if not ignore then
ignore = true
for x = 1,duration do
delayedCall(self.go.id,x,"sound", "lock_incorrect") --set sound effect
end
delayedCall(self.go.id,duration,"resetIgnore")
end
end
function sound(sample)
playSound(sample)
end
function resetIgnore()
ignore = false
end
Re: Question about sound loops.
Posted: Mon Apr 06, 2015 8:15 am
by trancelistic
Thanks to both of you. Uhm to Isaac:
delayedCall(self.go.id,x,"sound", "lock_incorrect") gives an error : "attempt to index field 'go' a nil value x"
No idea how to solve this.
yes I'm a noob haha.

sorry about that.
Re: Question about sound loops.
Posted: Mon Apr 06, 2015 8:24 am
by minmay
The script Isaac posted is only for Grimrock 2.
Re: Question about sound loops.
Posted: Mon Apr 06, 2015 8:30 am
by trancelistic
minmay wrote:The script Isaac posted is only for Grimrock 2.
Haha that explains it:)
Ahhhh I almost solved it then the editor crashed:S:S
Re: Question about sound loops.
Posted: Mon Apr 06, 2015 9:35 am
by trancelistic
Isaac I need 1 more time your help. I think I solved it with some timers combined and scripts.
The only thing that is happening now is: I destroy'd a lever. The timer later activates a script that will repawn the lever and that is connected to the same timers/scripts as the REAL lever was before it was destroyed.
However the script says now that the lever isn't found while I clearly pulled the lever in game. ( so it did respawned with the correct IDname)
Any idea's what I did wrong?
So basicly lever pulled == activated. It activates a timer, after 0.01 seconds it will run a script telling it to destroy that lever
Another timer after 12 secs runs a scritp to respawn that lever again on the same location and its linked again to the timers. However then I get the message that the lever isn't found ( But i see it being spawned in game)
O_O
I hope I made sense haaha.