icdb

[ComputerCraft] Remote (receiver)

Sep 17th, 2014
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. --receiver
  2. local function openRednet()
  3.   for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
  4.     if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
  5.       rednet.open(side)
  6.       return side
  7.     end
  8.   end
  9.   print("no modem present")
  10. end
  11.  
  12. side = openRednet()
  13. if side == nil then
  14. print("no modem found")
  15. else
  16.   while true do
  17.     event, id, message, distance = os.pullEvent("rednet_message")
  18.     print(message)
  19.     shell.switchTab(shell.openTab(message))
  20.     shell.exit()
  21.   end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment