Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local my_name = "rocket"
- local modem_pos = "bottom"
- local protocol = "door_control"
- local motor = peripheral.wrap("right")
- motor.stop()
- rednet.open(modem_pos)
- rednet.host(protocol, my_name)
- while true do
- local id, message = rednet.receive(protocol)
- if message == "open" then
- if redstone.getInput("left") then
- sleep(motor.rotate(-90, 10))
- motor.stop()
- print("Door opened by " .. id)
- else
- print("Door already open")
- end
- elseif message == "close" then
- if redstone.getInput("left") == false then
- sleep(motor.rotate(90, 10))
- motor.stop()
- print("Door closed by " .. id)
- else
- print("Door already closed")
- end
- else
- print("Message was not recognized " .. message .. " " .. id)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement