|
# File rbot/timer.rb, line 91
def tick
if(@lasttime != 0)
diff = (Time.now - @lasttime).to_f
@lasttime = Time.now
@timers.compact.each { |timer|
timer.in = timer.in - diff
}
@timers.compact.each { |timer|
if (!timer.blocked)
if(timer.in <= 0)
if(timer.run)
# run once
@timers.delete(timer)
end
end
end
}
else
# don't do anything on the first tick
@lasttime = Time.now
end
end
|