Difference between revisions of "Alarm (event)"
From ComputerCraft Wiki
m (Removed needs work box) |
(better coding habits) |
||
Line 6: | Line 6: | ||
{{Example | {{Example | ||
|desc=Sets the alarm for 1 (in-game) hour, then waits for the event to fire | |desc=Sets the alarm for 1 (in-game) hour, then waits for the event to fire | ||
− | |code=local alarm = os.setAlarm(os.time()+01.00) -- Sets the Alarm for 1 hour after the current time | + | |code=local alarm = os.setAlarm(os.time()+01.00) -- Sets the Alarm for 1 hour after the current time |
+ | while true do | ||
+ | local event, id = os.pullEvent("alarm") -- Waits for the alarm event | ||
+ | if id == alarm then -- Checks to see if it's the alarm we created | ||
+ | print("The alarm has gone off!") | ||
+ | break -- Get out of the loop | ||
+ | end | ||
+ | end | ||
}} | }} | ||
}} | }} |
Revision as of 09:40, 28 October 2013
Event alarm | |
Fired when an alarm has expired. | |
Returned Object 1 | The alarm's numerical representation value (returned when os.setAlarm() is initially called). |