Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- modem.open(43) -- Open channel 43 to receive messages
- clearScreen()
- modem.transmit(15, 43, "Remote Connected")
- local event, side, channel, replyChannel, message, distance
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 43
- print(tostring(message))
- -- Define the allowed options
- local allowedOptions = {"Bridge", "Courtyard", "Archive", "Stables", "Filters", "status"}
- -- Prompt the user to choose from the options
- print("Choose one of the following options:")
- for i, option in ipairs(allowedOptions) do
- print(i .. ". " .. option)
- end
- -- Validate user input
- local userInput
- repeat
- print("Enter the number corresponding to your choice:")
- userInput = tonumber(read())
- until userInput and allowedOptions[userInput]
- -- Send the chosen option
- local chosenOption = allowedOptions[userInput]
- modem.transmit(15, 43, chosenOption)
- clearScreen()
- -- Wait for a reply
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 43
- print(tostring(message))
Advertisement
Advertisement