I have made a .txt file with 20 sentences in it. I want to play these lines of text to the channel at 30 minute intervals. Only 1 line at a time...
Now ive got this: /timer.#hottubmessage 0 1800 play #hottub hottubmessage.txt 2000
It works fine, except every 30 minutes it plays all 20 lines of text to the channel with a 2 second delay between each line...
Is it possible to play only 1 line every 30 minutes respectively, 1 - 20 in order... and loop it?
because the timer calls the play command which plays all 20 lines with a determened delay in milliseconds
the best thing i could think to do is use
/play with a interval delay of $calc(30*60*1000)
that should give you you 30 minute delay
and then to loop it i guess .timer 0 $calc(20*30*60*1000)
.timer.#hottubmessage 0 $calc(20*30*60*1000) play #hottub hottubmessage.txt $calc(30*60*1000)
alias delayplay {
[color:green]; %readdelay is the incrementing variable[/color]
[color:green]; It starts at 0, so on first run it increments to 1[/color]
[color:green]; Subsequent calls will increment it by 1 (1..2..3...4...etc)[/color]
inc %readdelay
[color:green]; Set current line of the text file, according to %readdelay into %current and send to channel[/color]
var %current = $read(hottubmessage.txt, %readdelay)
msg #hottub %current
[color:green]; If %readdelay has reached the last line of the file, reset it to 0[/color]
if (%readdelay == $lines(hottubmessage.txt)) {
set %readdelay 0
}
}
alias startplay {
[color:green]; Unset %readdelay so it starts from the first line when this command is issued[/color]
unset %readdelay
.timerdelay 0 1800 delayplay
}
Use: /startplay
You can rename the aliases and variables to whatever you like, but be sure to change them in the script where applicable if you do so.
.timer.#hottubmessage 0 $calc(20*30*60*1000) play #hottub hottubmessage.txt $calc(30*60*1000)
Since this timer is not a millisecond timer (-m) it plays once per 416,666... days.
.timer.#hottubmessage 0 $calc(20*30*60*) play #hottub hottubmessage.txt $calc(30*60*1000)
yeah i was obviously zoned out
I dont think you shouyld use the play command like that. From what I know about it, once its playing no other play command can work untill its finished .
//timer.#hottubmessage 20 1800 msg #hottub $!read(hottubmessage.txt,nt,$calc(20 - $!timer($ctimer).reps)) $(|,) if (!$timer($ctimer).reps) $!+(timer,$ctimer) 20 1 $!timer($ctimer).com
^
that loops the 20 lines then relaunches the timer
//timer.#hottubmessage 20000 1800 msg #hottub $!read(hottubmessage.txt,nt,$calc(20 - $!timer($ctimer).reps % 20))
^
that just uses 20,000 iterations of the timer and keeps playing the file line 1 to 20, 1 to 20, 1 to 20 etc etc, so it does 1000 times through the file