Advertisement
Alexr360

Restricted Bastion Program

Mar 13th, 2024 (edited)
936
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 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 43 so we can receive replies
  8.  
  9. modem.transmit(15, 43, "Remote Connected")
  10.  
  11. local event, side, channel, replyChannel, message, distance
  12. repeat
  13.   event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  14. until channel == 43
  15.  
  16. clearScreen()
  17.  
  18. print(tostring(message))
  19.  
  20. os.sleep(1)
  21.  
  22. clearScreen()
  23.  
  24. -- Define the allowed options
  25. local allowedOptions = {"Fortress"}
  26.  
  27. -- Prompt the user to choose from the options
  28. print("Choose one of the following options:")
  29. for i, option in ipairs(allowedOptions) do
  30.   print(i .. ". " .. option)
  31. end
  32.  
  33. -- Validate user input
  34. local userInput
  35. repeat
  36.   print("Enter the number corresponding to your choice:")
  37.   userInput = tonumber(read())
  38. until userInput and allowedOptions[userInput]
  39.  
  40. -- Send the chosen option
  41. local chosenOption = allowedOptions[userInput]
  42. modem.transmit(15, 43, chosenOption)
  43.  
  44. clearScreen()
  45.  
  46. -- Wait for a reply
  47. repeat
  48.   event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  49. until channel == 43
  50.  
  51. clearScreen()
  52.  
  53. print(tostring(message))
  54.  
  55. os.sleep(1)
  56. shell.run("Greeting")
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement