pandorrama

Rocket

Apr 12th, 2021 (edited)
425
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- TO INSTALL JUST EXECUTE: pastebin get r3Tp66HT rocket.lua
  2.  
  3. local component = require("component")
  4. local compuer = require("computer")
  5. local shell = require("shell")
  6. local sides = require("sides")
  7. local arguments_as_a_table = {...}
  8. local detector = {}
  9.  
  10. AsteroidMiningalarm = component.proxy("c5f9cdeb-c716-4af2-8eee-81f821024568")
  11. AsteroidMiningControl = component.proxy("23102c98-d22c-4681-81d0-adccde1ffe4c")
  12. AsteroidMiningDoor = component.proxy("92071822-d613-4cc1-9681-fab59137adb0")
  13. AsteroidMiningDetector = component.proxy("02e26a3e-376c-4dd1-beba-75ff824b7314")
  14.  
  15. SateliteControl = component.proxy("e1b1214c-7312-441b-b076-64313d770667")
  16. SateliteDoor = component.proxy("b95684ae-d7c7-42c2-97bd-d8b04f98e7dc")
  17. SateliteDetector = component.proxy("db99befa-dfda-436c-a66a-d51184db5edf")
  18.  
  19. AstronautControl = component.proxy("")
  20. AstronautDoor = component.proxy("9e5f4eac-4686-4671-b643-1ccd9b07c887")
  21.  
  22. -- get parameter
  23. local function get_args()
  24.   if #arguments_as_a_table < 1 then
  25.     io.write("Useage: rocket <mining/satelite>\n")
  26.     io.write("what rocket platform to use\n")
  27.     os.exit()
  28.   end
  29.   operationPlatform = arguments_as_a_table[1]
  30. end
  31.  
  32. local function startRocket(alarm, door, control, detector)
  33.     alarm.setRange(3)
  34.     alarm.activate()
  35.     print("!!!Caution!!!")
  36.     print("Starting mining mission")
  37.     print("LEAVE rocket platform imidietly!!!")
  38.     os.sleep(3)
  39.     for t=10,0,-1 do
  40.         print("t - "..t)
  41.         os.sleep(1)
  42.     end
  43.      
  44.     --open door
  45.     door.setOutput(sides.south,15)
  46.     --start rocket
  47.     control.setOutput(sides.up,15)
  48.     os.sleep(1)
  49.     control.setOutput(sides.up,0)
  50.      
  51.     os.sleep(20)
  52.     alarm.deactivate()
  53.      
  54.     --wait for rocket
  55.     local rocketPresent = false
  56.     while rocketPresent == false do
  57.       local entityScan = detector.scanEntities(7)
  58.       if entityScan ~= false and #entityScan ~= 0 then
  59.         for k in pairs(entityScan) do
  60.           if entityScan[k].name == "Rocket" then
  61.             rocketPresent = true
  62.             print("rocket there: "..entityScan[k].name)
  63.           end
  64.         end
  65.       end
  66.       if rocketPresent == false then
  67.         print("rocket is absent, waiting...")
  68.         os.sleep(5)
  69.       end
  70.     end
  71.  
  72.     --close door
  73.     door.setOutput(sides.south,0)
  74. end
  75.  
  76.  
  77. --program starts here--
  78. get_args()
  79. if operationPlatform == "mining" then
  80.   startRocket(AsteroidMiningalarm, AsteroidMiningDoor, AsteroidMiningControl, AsteroidMiningDetector)
  81. elseif operationPlatform == "satelite" then
  82.   startRocket(AsteroidMiningalarm, SateliteDoor, SateliteControl, SateliteDetector)
  83. elseif operationPlatform == "astronaut" then
  84.   if AstronautDoor.getOutput()[3] == 15.0 then
  85.     AstronautDoor.setOutput(3,0)
  86.     print("opened, closing")
  87.   else
  88.     AstronautDoor.setOutput(3,15)
  89.     print("closed, opening")
  90.   end
  91. end
RAW Paste Data