Events are triggered when something happens in or outside the computer.

Use os.pullEvent() to hold the program until a system event occurs.

For example, to detect a redstone change connected to the computer:

r = os.pullEvent()

if r == "redstone" then -- If the event was a redstone change.

  --Do Something


To detect what side:

r, s = os.pullEvent()

r is the event and s is the side.

The possible events are:

Event Trigger Arguments
char Text is typed on the keyboard Letter typed
key Key is pressed on the keyboard Numerical keycode
timer Timeout started by os.startTimer() completed Value returned by startTimer()
raw Something updates the computer (redstone, text, so forth...) None
alarm Time passed to os.setAlarm() is reached Value returned by setAlarm()
redstone The state of any redstone input changes Side of the change

disk or disk_eject

Disk is inserted or removed from an adjacent disk drive. Side of the change


Received rednet message Value returned by rednet.receive()

(id of sender, message)

modem_message Received Modem message