Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- TO INSTALL JUST EXECUTE: pastebin get r3Tp66HT rocket.lua
- local component = require("component")
- local compuer = require("computer")
- local shell = require("shell")
- local sides = require("sides")
- local arguments_as_a_table = {...}
- local detector = {}
- AsteroidMiningalarm = component.proxy("c5f9cdeb-c716-4af2-8eee-81f821024568")
- AsteroidMiningControl = component.proxy("23102c98-d22c-4681-81d0-adccde1ffe4c")
- AsteroidMiningDoor = component.proxy("92071822-d613-4cc1-9681-fab59137adb0")
- AsteroidMiningDetector = component.proxy("02e26a3e-376c-4dd1-beba-75ff824b7314")
- SateliteControl = component.proxy("e1b1214c-7312-441b-b076-64313d770667")
- SateliteDoor = component.proxy("b95684ae-d7c7-42c2-97bd-d8b04f98e7dc")
- SateliteDetector = component.proxy("db99befa-dfda-436c-a66a-d51184db5edf")
- AstronautControl = component.proxy("")
- AstronautDoor = component.proxy("9e5f4eac-4686-4671-b643-1ccd9b07c887")
- -- get parameter
- local function get_args()
- if #arguments_as_a_table < 1 then
- io.write("Useage: rocket <mining/satelite>\n")
- io.write("what rocket platform to use\n")
- os.exit()
- end
- operationPlatform = arguments_as_a_table[1]
- end
- local function startRocket(alarm, door, control, detector)
- alarm.setRange(3)
- alarm.activate()
- print("!!!Caution!!!")
- print("Starting mining mission")
- print("LEAVE rocket platform imidietly!!!")
- os.sleep(3)
- for t=10,0,-1 do
- print("t - "..t)
- os.sleep(1)
- end
- --open door
- door.setOutput(sides.south,15)
- --start rocket
- control.setOutput(sides.up,15)
- os.sleep(1)
- control.setOutput(sides.up,0)
- os.sleep(20)
- alarm.deactivate()
- --wait for rocket
- local rocketPresent = false
- while rocketPresent == false do
- local entityScan = detector.scanEntities(7)
- if entityScan ~= false and #entityScan ~= 0 then
- for k in pairs(entityScan) do
- if entityScan[k].name == "Rocket" then
- rocketPresent = true
- print("rocket there: "..entityScan[k].name)
- end
- end
- end
- if rocketPresent == false then
- print("rocket is absent, waiting...")
- os.sleep(5)
- end
- end
- --close door
- door.setOutput(sides.south,0)
- end
- --program starts here--
- get_args()
- if operationPlatform == "mining" then
- startRocket(AsteroidMiningalarm, AsteroidMiningDoor, AsteroidMiningControl, AsteroidMiningDetector)
- elseif operationPlatform == "satelite" then
- startRocket(AsteroidMiningalarm, SateliteDoor, SateliteControl, SateliteDetector)
- elseif operationPlatform == "astronaut" then
- if AstronautDoor.getOutput()[3] == 15.0 then
- AstronautDoor.setOutput(3,0)
- print("opened, closing")
- else
- AstronautDoor.setOutput(3,15)
- print("closed, opening")
- end
- end
Add Comment
Please, Sign In to add comment