Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- STD_MODEM_SIDE = "left"
- PING_PONG_CHAN = 5
- function receivePing (message, dist)
- print("Received msg: " ..(message or "nil message").. "\n")
- print("Sender is " ..(tostring(dist) or "an unknown number of").. "blocks away.\n")
- end
- local modem = peripheral.wrap(STD_MODEM_SIDE)
- modem.open(PING_PONG_CHAN)
- print("Listening on channel: " ..tostring(PING_PONG_CHAN).. "\n")
- local event, side, senderChan, replyChan, message, dist = os.pullEvent("modem_message")
- receivePing(message, dist)
Advertisement
Add Comment
Please, Sign In to add comment