Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Initialize variables
- local channel = 11 -- Channel to send on
- local launchTarget = ""
- local destination = ""
- local modem = peripheral.find("modem")
- -- Planet and destination options
- local planets = { "Mars", "The Moon" }
- local destinations = { "Orbit", "Surface" }
- -- Welcome message
- print("Welcome to RareCorp. Space Command.")
- -- Function to display options and get selection
- local function getSelection(options)
- local selection = ""
- while true do
- for i, option in ipairs(options) do
- print(i .. ". " .. option)
- end
- local choice = tonumber(read())
- if choice and choice > 0 and choice <= #options then
- selection = options[choice]
- break
- else
- print("Invalid choice. Please try again.")
- end
- end
- return selection
- end
- -- Get launch target
- print("Where would you like to set your launch target to?")
- launchTarget = getSelection(planets)
- -- Get destination type
- print("Are you going to Orbit or Surface?")
- destination = getSelection(destinations)
- -- Save choices for later use (You can implement saving the data to a file or other storage if needed)
- -- Wait for launch command
- while true do
- print("Type 'launch' when ready.")
- local command = read()
- if command == "launch" then
- print("Launching to " .. launchTarget .. " (" .. destination .. ").")
- -- Send 'start' command
- redstone.setOutput("back", true)
- sleep(1)
- redstone.setOutput("back", false)
- modem.transmit(channel, channel + 1, "start")
- sleep(14)
- -- Send 'stop' command
- modem.transmit(channel, channel + 1, "stop")
- print("Launch sequence completed.")
- redstone.setOutput("back", true)
- sleep(1)
- redstone.setOutput("back", false)
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement