Advertisement
KingKevin23

launch_sequence

Aug 6th, 2023 (edited)
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local name = "monitor_0"
  2. local modem_pos = "back"
  3. local monitor = peripheral.find("monitor", function(n, monitor)
  4.     return n == name
  5. end)
  6. monitor.clear()
  7.  
  8. function writeMiddle(message)
  9.     monitor.clear()
  10.     local x, y = monitor.getSize()
  11.     y = math.ceil(y/2)
  12.     x = math.ceil((x - string.len(message))/2)
  13.     monitor.setCursorPos(x, y)
  14.     monitor.write(message)
  15. end
  16.  
  17. function launchSequence()
  18.     rednet.open(modem_pos)
  19.     writeMiddle("Starting...")
  20.     sleep(30)
  21.     for i=10,1,-1 do
  22.         writeMiddle(tostring(i))
  23.         if i == 5 then
  24.             local id = rednet.lookup("door_control", "rocket")
  25.             rednet.send(id, "open", "door_control")
  26.         end
  27.         sleep(1)
  28.     end
  29.    
  30.     writeMiddle("GO GO GO!")
  31.     rednet.close(modem_pos)
  32.     while true do
  33.         print("Mission complete? (y/n)")
  34.         if read() == "y" then
  35.             break
  36.         end
  37.     end
  38.  
  39.     rednet.open(modem_pos)
  40.     writeMiddle("Hangar closed!")
  41.     local id = rednet.lookup("door_control", "rocket")
  42.     rednet.send(id, "close", "door_control")
  43.     rednet.close(modem_pos)
  44. end
  45.  
  46. print("Initiating launch sequence")
  47. launchSequence()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement