Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function detectSeason()
- -- Check redstone input from the front
- if redstone.getInput("front") then
- return "Winter"
- -- Check redstone input from the back
- elseif redstone.getInput("back") then
- return "Summer"
- -- Check redstone input from the right
- elseif redstone.getInput("right") then
- return "Spring"
- -- Check redstone input from the left
- elseif redstone.getInput("left") then
- return "Fall"
- else
- -- No redstone input detected
- return "no season detected"
- end
- end
- 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 == "Season" then
- print(detectSeason())
- modem.transmit(43, 15, detectSeason())
- 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