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)
- modem.open(15) -- 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 == 15
- -- Process the received message based on its content
- if message == "Bridge" then
- print("Toggling Bridge Gate")
- 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
- elseif message == "Courtyard" then
- print("Toggling Courtyard Gate")
- redstone.setOutput("right", true) -- Emit a redstone signal to the right
- os.sleep(1) -- Keep the signal for 1 seconds
- redstone.setOutput("right", false) -- Turn off the redstone signal
- elseif message == "Remote Connected" then
- modem.transmit(43, 15, "Connected to Bastion Network")
- print("Remote Connected")
- elseif message == "Lockdown" then
- print("Toggling Lockdown")
- redstone.setOutput("front", true) -- Emit a redstone signal to the right
- os.sleep(1) -- Keep the signal for 1 seconds
- redstone.setOutput("front", false) -- Turn off the redstone signal
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Bastion Network Online!")
- -- Main loop
- while true do
- bastion()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement