Hydrotronics

Computercraft 1.5.8 rednet.repeat() 2.0

Aug 23rd, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. local function connect()
  4. for _,s in ipairs(rs.getSides()) do
  5.   if peripheral.isPresent(s) and peripheral.getType(s) == "modem" then
  6.    rednet.open(s)
  7.    return true
  8.   end
  9. end
  10. term.clear()
  11. print("ERROR")
  12. print("No modem found")
  13. print("Aborting")
  14. sleep(3)
  15. os.shutdown()
  16. return false
  17. end
  18. connect()
  19. i = 0
  20. while true do
  21. term.clear()
  22. term.setCursorPos(1,1)
  23. print (i.." messages passed")
  24. senderId, message, distance = rednet.receive()
  25. rednet.send(1,""..message) -- Modify the "1" to the id of the receiving computer
  26. i = i+1
  27. end
Advertisement
Add Comment
Please, Sign In to add comment