Difference between revisions of "Timer (event)"

From ComputerCraft Wiki
Jump to: navigation, search
m (May need more work)
m (Not 'numerical representation', 'unique ID'. os.startTimer() returns an ID.)
Line 4: Line 4:
 
|name=timer
 
|name=timer
 
|desc=Fired when a timer completes.
 
|desc=Fired when a timer completes.
|return1=The timer's numerical representation value (returned when [[os.startTimer|os.startTimer()]] is initially called).
+
|return1=The timer's unique ID value (returned when [[os.startTimer|os.startTimer()]] is called).
 
}}
 
}}
 
{{Example
 
{{Example

Revision as of 00:12, 8 July 2013

This page needs some serious TLC, stat!
Please help us by cleaning it, fixing it up, or sparing it some love.
(Reason: A demonstration on the use and handling of this event would be beneficial. AfterLifeLochie 16:11, 30 November 2012 (MSK))



Grid Modem.png  Event timer
Fired when a timer completes.
Returned Object 1 The timer's unique ID value (returned when os.startTimer() is called).


Grid paper.png  Example
This code will continuously start an internal timer and fire an event. If the event is not the timer, then it will break the loop
Code
while true do
os.startTimer(1)
event = os.pullEvent()
if event == "timer" then
print("Too slow!")
else
print("Darn, you beat me!")
break
end
end