Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("bottom")
- rednet.open("back")
- speaker = peripheral.wrap("left")
- function setState(con)
- redstone.setOutput("top", con)
- rednet.broadcast("n-word switched " .. con and "on" or "off" .. " at " .. textutils.formatTime(os.time()))
- local state = fs.open("last_state", "w")
- if con then
- speaker.playSound("minecraft:block.end_portal.spawn", 3)
- state.write("true")
- else
- state.write("false")
- speaker.playSound("minecraft:entity.wolf.whine", 3)
- end
- end
- laststate = fs.open("last_state", "w")
- if laststate.readAll() == "true" then
- setState(true)
- end
- while true do
- id,message = rednet.receive("n")
- print("[" .. id .. "] " .. message)
- if id == 124 and message == "turn_on" then
- setState(true)
- elseif id == 124 and message == "turn_off" then
- setState(false)
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement