Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function bastion()
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- local name = "Archives"
- modem.open(14) -- Open 43 so we can receive replies
- -- And wait for a reply
- local event, side, channel, replyChannel, message, distance
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 14
- -- Process the received message based on its content
- if message == "1" then
- print("Opening " .. name)
- modem.transmit(42, 14, "Opening " .. name)
- redstone.setOutput("left", true) -- Emit a redstone signal to the right
- os.sleep(1) -- Keep the signal for 1 seconds
- redstone.setOutput("left", false) -- Turn off the redstone signal
- print("Closing " .. name)
- modem.transmit(42, 14, "Closing " .. name)
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Speak friend and enter!")
- -- Main loop
- while true do
- bastion()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement