pandorrama

GasMining

May 9th, 2021 (edited)
633
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- TO INSTALL JUST EXECUTE: pastebin get W8StF2e0 gasmining.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. GasMiningAlarm = component.proxy("5787f052-4b3a-4882-9314-bcf26a68c82c")
  11. GasMiningControl = component.proxy("1b1103ea-3683-4177-854e-0fbe11efb5b1")
  12. GasMiningDoorUp = component.proxy("7e686f3e-3791-4b80-af3d-70e6a21642c2")
  13. GasMiningDoorDown = component.proxy("4030d6f6-4f5a-4467-9826-138fa6d70940")
  14. GasMiningDetector = component.proxy("e2f77baa-394c-4dae-9d66-3a2adedc3ae0")
  15.  
  16.  
  17. local function startRocket(alarm, doorUp, doorDown, control, detector)
  18.   alarm.setRange(2)
  19.   alarm.activate()
  20.   print("!!!Caution!!!")
  21.   print("Starting mining mission")
  22.   print("LEAVE rocket platform imidietly!!!")
  23.   print("We will lock doors soon")
  24.   os.sleep(3)
  25.   for t=10,0,-1 do
  26.     print("t - "..t)
  27.     os.sleep(1)
  28.   end
  29.  
  30.   doorUp.setOutput(sides.up,15)
  31.   os.sleep(3)
  32.   doorDown.setOutput(sides.up,0)
  33.  
  34.   --start rocket
  35.   control.setOutput(sides.up,15)
  36.   os.sleep(1)
  37.   control.setOutput(sides.up,0)
  38.  
  39.   os.sleep(20)
  40.   alarm.deactivate()
  41.  
  42.   --wait for rocket
  43.   local rocketPresent = false
  44.   while rocketPresent == false do
  45.     local entityScan = detector.scanEntities(7)
  46.     if entityScan ~= false and #entityScan ~= 0 then
  47.       for k in pairs(entityScan) do
  48.         if entityScan[k].name == "entity.deployedRocket.name" then
  49.           rocketPresent = true
  50.           print("rocket there: "..entityScan[k].name)
  51.         end
  52.       end
  53.     end
  54.     if rocketPresent == false then
  55.     print("rocket is absent, waiting...")
  56.     os.sleep(5)
  57.     end
  58.   end
  59.  
  60.   --close door
  61.   os.sleep(3)
  62.   doorDown.setOutput(sides.up,15)
  63.   os.sleep(3)
  64.   doorUp.setOutput(sides.up,0)
  65.   os.sleep(3)
  66. end
  67.  
  68.  
  69. --program starts here--
  70. startRocket(GasMiningAlarm, GasMiningDoorUp, GasMiningDoorDown, GasMiningControl, GasMiningDetector)
RAW Paste Data