Avorius1337

Untitled

Dec 24th, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. modem = peripheral.wrap("left")
  2. rednet.open("left")
  3.  
  4. pd = peripheral.find("playerDetector")
  5. if pd == nil then error("playerDetector not found") end
  6.  
  7. if rednet.isOpen() then
  8. print("Rednet online")
  9. else
  10. print("Rednet failed to load")
  11. return
  12. end
  13.  
  14. function rednetMsgs()
  15. while true do
  16. local id, msg = rednet.receive()
  17. if id == 2 or id == 4 or id == 10 then
  18. if msg == "windmill" then
  19. if redstone.getOutput("top") then
  20. redstone.setOutput("top", false)
  21. else
  22. redstone.setOutput("top", true)
  23. end
  24. end
  25. end
  26. end
  27. end
  28.  
  29. function playerFind()
  30. while true do
  31. local plys = pd.getPlayersInRange(3)
  32. if redstone.getOutput("top") then
  33. if #plys == 0 then
  34. redstone.setOutput("top", false)
  35. end
  36. end
  37. sleep(1)
  38. end
  39. end
  40.  
  41. parallel.waitForAll(rednetMsgs,playerFind)
Advertisement
Add Comment
Please, Sign In to add comment