Advertisement
maxheyer

Untitled

Jan 14th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. if component == nil then
  2. component = require("component")
  3. end
  4.  
  5. local function proxy(name, required)
  6. local address = component and component.list(name)()
  7. if not address and required then
  8. error("Missing component '" .. name .. "'")
  9. end
  10. return address and component.proxy(address) or nil
  11. end
  12.  
  13. local modem = proxy("modem", true)
  14. modem.open(1)
  15. modem.setStrength(500)
  16.  
  17. local robot = proxy("robot", true)
  18.  
  19. while true do
  20. local signal, _, remoteAddress, port, distance, payload = computer.pullSignal()
  21.  
  22. if signal == "modem_message" then
  23. if payload == "ping" then
  24. computer.beep()
  25. modem.send(remoteAddress, port, "pong", robot.name())
  26. else
  27. pcall(load(payload))
  28. end
  29. end
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement