SashaFierce
08-24-2015, 07:00 PM
Here is what I'm trying to do:
I want to time my arena run, and send the final result to a specific lnet channel "DuskRuin"
TOP:
match "START", "Introducing our new challenger"
match "FINISH", "is triumphant, defeating all those that opposed"
matchwait
START:
#respond Time.now
CharSettings['duration'] = Time.now
CharSettings['timequit'] ||= Time.now
timerested = Time.now - CharSettings['timequit']
Thread.new{loop {CharSettings['timequit'] = Time.now; pause 1}}
goto "TOP"
FINISH:
#respond Time.now
duration = Time.now - CharSettings['duration']
hours = (duration / 3600).to_i
minutes = (duration / 60 - hours * 60).to_i
seconds = (duration - 60 * minutes - 3600 * hours).to_i
respond "[ Arena Ended. #{hours}h:#{'%02d' %minutes}m:#{'%02d' %seconds}s. ]"
result='[Arena Ended - #{hours}h:#{'%02d' %minutes}m:#{'%02d' %seconds}s. ]'
send_to_script 'lnet', 'chat '+result'
goto "TOP"
The problem is the
'%02d'
The result I get is:
--- Lich: error: ArenaTimer:7: syntax error, unexpected tIDENTIFIER, expecting end-of-input
...Arena Ended - #{hours}h:#{'%02d' %minutes}m:#{'%02d' %second...
... ^
C:/Users/MEDIA/Documents/lich/lich.rbw:2517:in `eval'
C:/Users/MEDIA/Documents/lich/lich.rbw:2517:in `block (3 levels) in <class:Script>'
--- Lich: ArenaTimer has exited.
#LNet.send_message(attr={'type'=>'channel'}, DUSKRUIN, ["Arena Ended - #{hours}h:#{'%02d' %minutes}m:#{'%02d' %seconds}s."])
This works, if I remove the ' ' around %02d but then the time portion breaks.
I want to time my arena run, and send the final result to a specific lnet channel "DuskRuin"
TOP:
match "START", "Introducing our new challenger"
match "FINISH", "is triumphant, defeating all those that opposed"
matchwait
START:
#respond Time.now
CharSettings['duration'] = Time.now
CharSettings['timequit'] ||= Time.now
timerested = Time.now - CharSettings['timequit']
Thread.new{loop {CharSettings['timequit'] = Time.now; pause 1}}
goto "TOP"
FINISH:
#respond Time.now
duration = Time.now - CharSettings['duration']
hours = (duration / 3600).to_i
minutes = (duration / 60 - hours * 60).to_i
seconds = (duration - 60 * minutes - 3600 * hours).to_i
respond "[ Arena Ended. #{hours}h:#{'%02d' %minutes}m:#{'%02d' %seconds}s. ]"
result='[Arena Ended - #{hours}h:#{'%02d' %minutes}m:#{'%02d' %seconds}s. ]'
send_to_script 'lnet', 'chat '+result'
goto "TOP"
The problem is the
'%02d'
The result I get is:
--- Lich: error: ArenaTimer:7: syntax error, unexpected tIDENTIFIER, expecting end-of-input
...Arena Ended - #{hours}h:#{'%02d' %minutes}m:#{'%02d' %second...
... ^
C:/Users/MEDIA/Documents/lich/lich.rbw:2517:in `eval'
C:/Users/MEDIA/Documents/lich/lich.rbw:2517:in `block (3 levels) in <class:Script>'
--- Lich: ArenaTimer has exited.
#LNet.send_message(attr={'type'=>'channel'}, DUSKRUIN, ["Arena Ended - #{hours}h:#{'%02d' %minutes}m:#{'%02d' %seconds}s."])
This works, if I remove the ' ' around %02d but then the time portion breaks.