If you just want a solution for now: http://lua-users.org/wiki/ForTutorial
[lua]
local min = 60
for k, name in pairs(SpookyFunctions) do
local timeleft = timer.TimeLeft(name)
if timeleft ~= nil and timeleft < min then
min = timeleft
end
end
if min < 60 and timer.TimeLeft(“Spooky Muffled Cry”) < 20 then
– do whatever
end
[/lua]
[editline]20th October 2017[/editline]
So, after reading your pastebin link – you want all the other sounds to play independently, no matter how close to one other, and town_muffled_cry1.wav is the only one that delays itself after one of the others plays, right?
You don’t need to use a Tick hook for this – try using a local variable to store the last time one of the other timers went off, and then have SpookyMuffledCry delay itself:
[lua]
local lastSound = 0
local function SpookyChildScream()
for k,v in pairs(player.GetAll()) do
v:SendLua(“surface.PlaySound(“ambient/creatures/town_child_scream1.wav”)”)
end
lastSound = CurTime()
end
local function SpookyMuffledCry()
if lastSound + 20 > CurTime() then
timer.Adjust(“Spooky Muffled Cry”, …)
return
end
for k,v in pairs(player.GetAll()) do
v:SendLua(“surface.PlaySound(“ambient/creatures/town_muffled_cry1.wav”)”)
end
end
[/lua]