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
- os.sleep(1)
- if redstone.getInput("left") then
- modem.transmit(43, 15, "Closing Bridge Gate")
- else
- modem.transmit(43, 15, "Opening Bridge Gate")
- end
- elseif message == "Courtyard" then
- os.sleep(1)
- if redstone.getInput("right") then
- modem.transmit(43, 15, "Closing Courtyard Gate")
- else
- modem.transmit(43, 15, "Opening Courtyard Gate")
- end
- elseif message == "status" then
- courtyard = ""
- bridge = ""
- lockdown = ""
- if redstone.getInput("right") then
- courtyard = "Courtyard Gate Closed, "
- else
- courtyard = "Courtyard Gate Open, "
- end
- if redstone.getInput("left") then
- bridge = "Bridge Gate Closed, "
- else
- bridge = "Bridge Gate Open, "
- end
- if redstone.getInput("back") then
- lockdown = "Lockdown Enabled"
- else
- lockdown = "Lockdown Disabled"
- end
- modem.transmit(43, 15, courtyard .. bridge .. lockdown)
- elseif message == "Lockdown" then
- os.sleep(1)
- if redstone.getInput("back") then
- modem.transmit(43, 15, "Enabeling Lockdown")
- else
- modem.transmit(43, 15, "Disabeling Lockdown")
- end
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Bastion Online!")
- -- Main loop
- while true do
- bastion()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement