on *:TEXT:!start:#:{
if ($($+(%,stopwatch.start.,$nick),2)) {
msg $chan You already have a stopwatch running.
}
elseif ($($+(%,stopwatch.pause.,$nick),2)) {
msg $chan You already have a stopwatch running (paused).
}
else {
set $+(%,stopwatch.start.,$nick) $ctime
msg $chan Stopwatch started.
}
}
on *:TEXT:!stop:#:{
if (!$($+(%,stopwatch.start.,$nick),2)) {
msg $chan You do not have a stopwatch running.
}
elseif ($($+(%,stopwatch.pause.,$nick),2)) {
msg $chan You cannot stop a stopwatch that is paused.
}
else {
var %dur = $duration($calc($ctime - $($+(%,stopwatch.start.,$nick),2) + $iif($($+(%,stopwatch.add.,$nick),2),$v1,0)))
unset $+(%,stopwatch.*.,$nick)
msg $chan Stopwatch stopped after %dur
}
}
on *:TEXT:!pause:#:{
if (!$($+(%,stopwatch.start.,$nick),2)) {
msg $chan You do not have a stopwatch running.
}
elseif ($($+(%,stopwatch.pause.,$nick),2)) {
msg $chan Your stopwatch has already been paused.
}
else {
inc $+(%,stopwatch.add.,$nick) $calc($ctime - $($+(%,stopwatch.start.,$nick),2))
set $+(%,stopwatch.pause.,$nick) true
unset $+(%,stopwatch.start.,$nick)
msg $chan Stopwatch paused.
}
}
on *:TEXT:!continue:#:{
if ($($+(%,stopwatch.start.,$nick),2)) {
msg $chan Your stopwatch is not currently paused.
}
elseif (!$($+(%,stopwatch.pause.,$nick),2)) {
msg $chan You do not have a stopwatch running.
}
else {
set $+(%,stopwatch.start.,$nick) $ctime
unset $+(%,stopwatch.pause.,$nick)
msg $chan Stopwatch resumed.
}
}