Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Meridius_IX's Altitude Timer Trigger V.1.1
- //Script will trigger named timer once ship altitude is less than specified value.
- string timer_name = "Timer Block"; //Must be exact name of timer block to trigger
- string cockpit_name = "Cockpit"; //Must be exact name of cockpit used for measuring altitude
- double altitudeTrigger = 500; //If Ship is lower than this altitude, Timer will Trigger
- //////////////////////////////////////////////////////
- //Do Not Touch Anything Below Here
- //////////////////////////////////////////////////////
- IMyShipController cockpit;
- IMyTimerBlock timer;
- void Main(string argument){
- cockpit = null;
- List<IMyTerminalBlock> cockpit_list = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyShipController>(cockpit_list);
- timer = GridTerminalSystem.GetBlockWithName(timer_name) as IMyTimerBlock;
- if(cockpit_list.Count != 0){
- for(int i = 0; i < cockpit_list.Count; i++){
- if(cockpit_list[i].IsFunctional == true && cockpit_list[i].CustomName == cockpit_name){
- cockpit = cockpit_list[i] as IMyShipController;
- break;
- }
- }
- }
- if(cockpit == null){
- Echo("No Cockpit with name " + cockpit_name + " was found. Script Cannot Execute.");
- return;
- }
- if(timer == null){
- Echo("No Timer Block with name " + timer_name + " was found. Script Cannot Execute.");
- return;
- }
- double altitude = 0;
- bool gotElevation = cockpit.TryGetPlanetElevation(MyPlanetElevation.Surface, out altitude);
- if(altitude < altitudeTrigger && gotElevation == true){
- timer.ApplyAction("TriggerNow");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement