Hello, I want my colour trigger to have a countdown timer so it does go off too many times in a row, say a 5 second wait.
The line to play the sound is:
PlaySound (0, IsSound, false, 0, 0)
I assume I want some kind of for statement beforehand with a timer, but I don't know where to start.
Thanks!
You can use the Lua function os.time to find the current time in seconds.
What I would do is store that in a global variable, in your trigger, if the variable is not already set. Something like this:
<triggers>
<trigger
enabled="y"
match="foo"
send_to="12"
sequence="100"
>
<send>
-- if 10 seconds are up forget about when it last fired and zero the counter
if recentTimeTriggerFired then
if os.difftime (os.time (), recentTimeTriggerFired) >= 10 then
timesTriggerNoticed = 0
end -- if over 10 seconds since last time
-- IF less than 5 seconds have elapsed
-- AND it has fired more than 3 times
-- THEN play the sound
if os.difftime (os.time (), recentTimeTriggerFired) <= 5 and
timesTriggerNoticed >= 3 then
check (PlaySound (0, "tada.wav"))
timesTriggerNoticed = 0
end -- end of 3 times in a row with the most recent less than 5 seconds ago
end -- if it fired before
recentTimeTriggerFired = os.time ()
timesTriggerNoticed = (timesTriggerNoticed or 0) + 1
</send>
</trigger>
</triggers>
For advice on how to copy the above, and paste it into MUSHclient, please see
Pasting XML.