Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- modem.open(42) -- Open channel 42 to receive messages
- modem.transmit(14, 42, "Remote Connected")
- -- Define the allowed options
- local allowedOptions = {"Archives", "Stables", "Lower Bridge", "Upper Bridge", "Entryway", "Turbine Room"}
- -- 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(14, 42, chosenOption)
- -- Wait for a reply
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 42
- print(tostring(message))
- -- Wait for second reply
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 42
- print(tostring(message))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement