atlasim

listen modem

Jun 19th, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.38 KB | None | 0 0
  1. local modem = peripheral.find("modem") or error("No modem attached", 0)
  2. modem.open(0)
  3.  
  4. while true do
  5.     local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  6.     print(("Message received on side %s on channel %d (reply to %d) from %f blocks away with message %s"):format(
  7.         side, channel, replyChannel, distance, tostring(message)
  8.     ))
  9. end
Add Comment
Please, Sign In to add comment