Advertisement
Alexr360

Restricted Bastion Program

Mar 13th, 2024 (edited)
740
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. local function clearScreen()
  2.   term.clear()
  3.   term.setCursorPos(1, 1)
  4. end
  5.  
  6. local modem = peripheral.find("modem") or error("No modem attached", 0)
  7. modem.open(43) -- Open channel 43 to receive messages
  8.  
  9. clearScreen()
  10.  
  11. modem.transmit(15, 43, "Remote Connected")
  12.  
  13. local event, side, channel, replyChannel, message, distance
  14. repeat
  15.   event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  16. until channel == 43
  17.  
  18. print(tostring(message))
  19.  
  20. -- Define the allowed options
  21. local allowedOptions = {"Bridge", "Courtyard", "Archive", "Stables", "Filters", "status"}
  22.  
  23. -- Prompt the user to choose from the options
  24. print("Choose one of the following options:")
  25. for i, option in ipairs(allowedOptions) do
  26.   print(i .. ". " .. option)
  27. end
  28.  
  29. -- Validate user input
  30. local userInput
  31. repeat
  32.   print("Enter the number corresponding to your choice:")
  33.   userInput = tonumber(read())
  34. until userInput and allowedOptions[userInput]
  35.  
  36. -- Send the chosen option
  37. local chosenOption = allowedOptions[userInput]
  38. modem.transmit(15, 43, chosenOption)
  39.  
  40. clearScreen()
  41.  
  42. -- Wait for a reply
  43. repeat
  44.   event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  45. until channel == 43
  46.  
  47. print(tostring(message))
  48.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement