Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. rednet.open("bottom")
  2. rednet.open("back")
  3. speaker = peripheral.wrap("left")
  4.  
  5. function setState(con)
  6. redstone.setOutput("top", con)
  7. rednet.broadcast("n-word switched " .. con and "on" or "off" .. " at " .. textutils.formatTime(os.time()))
  8. local state = fs.open("last_state", "w")
  9. if con then
  10. speaker.playSound("minecraft:block.end_portal.spawn", 3)
  11. state.write("true")
  12. else
  13. state.write("false")
  14. speaker.playSound("minecraft:entity.wolf.whine", 3)
  15. end
  16. end
  17.  
  18. laststate = fs.open("last_state", "w")
  19. if laststate.readAll() == "true" then
  20. setState(true)
  21. end
  22.  
  23. while true do
  24. id,message = rednet.receive("n")
  25. print("[" .. id .. "] " .. message)
  26. if id == 124 and message == "turn_on" then
  27. setState(true)
  28. elseif id == 124 and message == "turn_off" then
  29. setState(false)
  30. end
  31. sleep(0.1)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement