Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. local name = "" --> What should this computer be called ex: Farm, mob spawner, etc.
  2. local updatetime = 60 --> How long (in seconds) to wait before requesting an update
  3. local modem = "right" --> set this to the side the modem is on
  4. local sides = { --> Modify this list to include sides you want to output redstone on
  5. "top",
  6. "front",
  7. "left",
  8. "right",
  9. "back",
  10. "bottom",
  11. }
  12.  
  13. function disable()
  14. for i in pairs(sides) do
  15. redstone.setOutput(sides[i], false)
  16. end
  17. end
  18.  
  19. function enable()
  20. for i in pairs(sides) do
  21. redstone.setOutput(sides[i], true)
  22. end
  23. end
  24.  
  25. function processResponse(response)
  26. if response == "offline" then
  27. disable()
  28. elseif response == "online" then
  29. enable()
  30. end
  31. end
  32.  
  33. function requestUpdate()
  34. serverID = rednet.lookup("AceDetectionCom", "OnlineDetectionServer")
  35. rednet.send(serverID, name, "update")
  36. end
  37.  
  38. rednet.open(modem)
  39.  
  40. while true do
  41. requestUpdate()
  42. senderId, message, protocol = rednet.receive("response", 10)
  43.  
  44.  
  45. if senderId ~= nil then
  46. print("Response received, status is: "..message)
  47. processResponse(message)
  48. else
  49. print("No response.")
  50. end
  51. sleep(updatetime)
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement