示例#1
0
        private bool GetObstructionStatus()
        {
            var group = GridTerminalSystem.GetBlockGroupWithName(AL_SENSORS);

            if (group == null)
            {
                return(false);
            }
            group.GetBlocks(blocks);

            try
            {
                for (var i = 0; i < blocks.Count; i++)
                {
                    var sensor = blocks[i] as IMySensorBlock;
                    if (sensor != null)
                    {
                        if (sensor.IsActive)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
            finally
            {
                blocks.Clear();
            }
        }
示例#2
0
 public void GetPistons(string name)
 {
     if (GridTerminalSystem.GetBlockWithName(name) as IMyPistonBase != null)
     {
         pistons.Add(GridTerminalSystem.GetBlockWithName(name) as IMyPistonBase);
     }
     else
     {
         if (GridTerminalSystem.GetBlockGroupWithName(name) != null)
         {
             IMyBlockGroup           tempGroup = GridTerminalSystem.GetBlockGroupWithName(name);
             List <IMyTerminalBlock> tempList  = new List <IMyTerminalBlock>();
             tempGroup.GetBlocks(tempList);
             for (int i = 0; i < tempList.Count; i++)
             {
                 pistons.Add(tempList[i] as IMyPistonBase);
             }
             if (pistons.Count == 0)
             {
                 throw new System.InvalidOperationException(name + " not found");
             }
         }
         else
         {
             throw new System.InvalidOperationException(name + " not found");
         }
     }
 }
        public Program()
        {
            _DebugLCD             = (IMyTextSurface)GridTerminalSystem.GetBlockWithName("Debug LCD");
            _DebugLCD.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            _DebugLCD.FontSize    = 2;
            _DebugLCD.Alignment   = VRage.Game.GUI.TextPanel.TextAlignment.CENTER;

            _RotorY = (IMyMotorStator)GridTerminalSystem.GetBlockWithName("RotorY");
            _RotorX = (IMyMotorStator)GridTerminalSystem.GetBlockWithName("RotorX");
            _RotorZ = (IMyMotorStator)GridTerminalSystem.GetBlockWithName("RotorZ");

            _RotorY.TargetVelocityRPM = .2f;
            _RotorX.TargetVelocityRPM = .2f;
            _RotorZ.TargetVelocityRPM = .2f;
            _RotorY.Torque            = 1500000f;
            _RotorX.Torque            = 1500000f;
            _RotorZ.Torque            = 1500000f;

            List <IMyTerminalBlock> tempList = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlockGroupWithName("Solar Panels").GetBlocksOfType <IMySolarPanel>(tempList);

            _SolarPanels = tempList.Cast <IMySolarPanel>().ToList();

            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
示例#4
0
        private List <SolarArray> InitSolarArrays()
        {
            var solarArrayNames = GetSolarArrayNames();
            var solarArrays     = new List <SolarArray>(solarArrayNames.Count);

            foreach (var solarArrayName in solarArrayNames)
            {
                var solarArrayGroup = GridTerminalSystem.GetBlockGroupWithName(solarArrayName);

                if (solarArrayGroup == null)
                {
                    Echo($"No group named '{solarArrayName}' found. Skipping this entry.");
                    continue;
                }

                var panels  = new List <IMySolarPanel>();
                var stators = new List <IMyMotorStator>();

                solarArrayGroup.GetBlocksOfType(panels);
                solarArrayGroup.GetBlocksOfType(stators);

                var drivingRotor = GetSingleRotorByTag(stators, drivingRotorTag);
                var bearing      = GetSingleRotorByTag(stators, bearingRotorTag);

                solarArrays.Add(new SolarArray {
                    Label = solarArrayName, Panels = panels, DrivingRotor = drivingRotor, Bearing = bearing, PreviousMaxOutput = 0, MovementStatus = SolarArrayMovementStatus.Stopped
                });
            }
            return(solarArrays);
        }
示例#5
0
        public Program()
        {
            rotor = (IMyMotorBase)GridTerminalSystem.GetBlockWithName("Advanced Rotor");

            pistons = GridTerminalSystem.GetBlockGroupWithName("Crane Pisonts");
            pistons.GetBlocksOfType <IMyPistonBase>(cranePistons);
            horizontal1 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Horizontal 1");
            horizontal2 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Horizontal 2");
            horizontal3 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Horizontal 3");

            vertical1 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Vertical 1");
            vertical2 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Vertical 2");
            vertical3 = (IMyPistonBase)GridTerminalSystem.GetBlockWithName("Piston Crane Vertical 3");

            Echo("Status");
            Echo("-------------------------------------------");
            Echo("Rotor: " + (rotor == null ? "Not Available" : "Ok"));
            Echo("Crane Pistons: " + (pistons == null ? "Not Available" : "Ok") + " / " + (cranePistons == null ? "Not Available" : "Ok"));
            Echo(" - Horizontal 1: " + (horizontal1 == null ? "Not Available" : "Ok"));
            Echo(" - Horizontal 2: " + (horizontal2 == null ? "Not Available" : "Ok"));
            Echo(" - Horizontal 3: " + (horizontal3 == null ? "Not Available" : "Ok"));
            Echo(" - Vertical 1: " + (vertical1 == null ? "Not Available" : "Ok"));
            Echo(" - Vertical 2: " + (vertical2 == null ? "Not Available" : "Ok"));
            Echo(" - Vertical 3: " + (vertical3 == null ? "Not Available" : "Ok"));
        }
示例#6
0
        public void Main(string argument, UpdateType updateSource)
        {
            var lcdGroup = GridTerminalSystem.GetBlockGroupWithName(DjConfig.PPOLcdGroupName);
            List <IMyTextPanel> myPPOLcdPanels = new List <IMyTextPanel>();

            lcdGroup.GetBlocksOfType(myPPOLcdPanels);

            /*var hydroLcdGroup = GridTerminalSystem.GetBlockGroupWithName(DjConfig.HydroLcdGroupName);
             * List<IMyTextPanel> myHydroLcdPanels = new List<IMyTextPanel>();
             * hydroLcdGroup.GetBlocksOfType(myHydroLcdPanels);*/

            if (myPPOLcdPanels.Count <= 0 /*&& myHydroLcdPanels.Count <= 0*/)
            {
                Echo($"Groups \"{DjConfig.PPOLcdGroupName}\" and \"{DjConfig.HydroLcdGroupName}\" are empty!");
                return;
            }
            if (myPPOLcdPanels.Count >= 0)
            {
                SolarStuff();
                ReactorStuff();

                WriteTextOnList(myPPOLcdPanels, DjConfig.message);
            }

            /*if (myHydroLcdPanels.Count >= 0)
             * {
             *  HydroStuff(myHydroLcdPanels);
             * }          */
        }
示例#7
0
        public void Main(string argument, UpdateType updateSource)
        {
            List <IMyTerminalBlock>  blocks     = new List <IMyTerminalBlock>();
            List <IMyTextPanel>      panels     = new List <IMyTextPanel>();
            List <IMyCargoContainer> containers = new List <IMyCargoContainer>();
            IMyBlockGroup            group;

            group = GridTerminalSystem.GetBlockGroupWithName(groupName);
            if (group != null)
            {
                group.GetBlocks(blocks);
                foreach (IMyTerminalBlock block in blocks)
                {
                    checkGrid = true;
                    gridName  = block.CubeGrid.ToString();
                    Echo("will only take blocks from grid " + gridName);
                    break;
                }
            }
            else
            {
            }

            GridTerminalSystem.GetBlocksOfType(panels, blk => (blk is IMyTextPanel));
            foreach (IMyTextPanel panel in panels)
            {
                panel.CustomData = "";
            }
            Echo("cleared custom data from " + panels.Count.ToString() + " panels.");
            GridTerminalSystem.GetBlocksOfType(containers, blk => (blk is IMyCargoContainer));
            clearCargoInfo(containers);
        }
        // Method for finding block groups
        List <IMyTerminalBlock> GetBlocksFromGroup(string group)
        {
            IMyBlockGroup           taggedGroup = GridTerminalSystem.GetBlockGroupWithName(group);
            List <IMyTerminalBlock> listGroup   = new List <IMyTerminalBlock>();
            List <IMyTerminalBlock> finallist   = new List <IMyTerminalBlock>();

            if (taggedGroup != null)
            {
                taggedGroup.GetBlocks(listGroup);
            }

            //check group tagged blocks are of right type
            for (int i = 0; i < listGroup.Count; i++)
            {
                if (listGroup[i] is IMyTextPanel)//Can be made generic
                {
                    finallist.Add(listGroup[i]);
                }
            }
            if (finallist != null)
            {
                return(finallist);
            }
            throw new Exception("GetBlocksFromGroup: Group \"" + group + "\" not found");
        }
示例#9
0
        public Program()
        {
            _stateMachine = Init();
            //Get Block Group
            blocks = GridTerminalSystem.GetBlockGroupWithName("Grav Lift");

            //Get Ship Controller as Reference

            List <IMyShipController> controllers = new List <IMyShipController>();

            blocks.GetBlocksOfType(controllers, x => x.CubeGrid == Me.CubeGrid);

            if (controllers.Count == 0)
            {
                Echo("No Remote Control or Cockpit found");
                return;
            }
            reference = controllers[0];

            //Get sensors
            blocks.GetBlocksOfType(sensors, x => x.CubeGrid == Me.CubeGrid);

            //Create a Station for each button Panel
            List <IMyButtonPanel> panels = new List <IMyButtonPanel>();

            blocks.GetBlocksOfType(panels, x => x.CubeGrid == Me.CubeGrid);
            stations = new Station[panels.Count];
            for (int i = 0; i < panels.Count; i++)
            {
                stations[i] = new Station(panels[i]);
            }
            Runtime.UpdateFrequency = UpdateFrequency.Once;
        }
示例#10
0
        void Main(string argument, UpdateType updateSource)
        {
            if (argument == "OpenHangar1")
            {
                var hangarGroup = GridTerminalSystem.GetBlockGroupWithName("Hangar 1");
                List <IMyAirtightHangarDoor> doors = new List <IMyAirtightHangarDoor>();
                hangarGroup.GetBlocksOfType(doors);

                foreach (var door in doors)
                {
                    door.SetValue("Open", true);
                }
            }
            if (argument == "CloseHangar1")
            {
                var hangarGroup = GridTerminalSystem.GetBlockGroupWithName("Hangar 1");
                List <IMyAirtightHangarDoor> doors = new List <IMyAirtightHangarDoor>();
                hangarGroup.GetBlocksOfType(doors);

                foreach (var door in doors)
                {
                    door.SetValue("Open", false);
                }
            }
        }
示例#11
0
        public Program()
        {
            switch (tickRate)
            {
            case 1:
                Runtime.UpdateFrequency = UpdateFrequency.Update1;
                break;

            case 10:
                Runtime.UpdateFrequency = UpdateFrequency.Update10;
                break;

            case 100:
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
                break;
            }

            IMyBlockGroup grp = GridTerminalSystem.GetBlockGroupWithName(LIGHT_RUNWAY_GROUP);

            if (grp != null)
            {
                List <IMyLightingBlock> li = new List <IMyLightingBlock>();
                grp.GetBlocksOfType <IMyLightingBlock>(li, b => b.CubeGrid == Me.CubeGrid);
                foreach (IMyLightingBlock b in li)
                {
                    lights.Add(new Light(b, colorList));
                }
            }
        }
示例#12
0
        private bool setup()
        {
            setupComplete = false;

            allBlocks     = new List <IMyTerminalBlock>();
            allBlocksTemp = new List <IMyTerminalBlock>();

            var grouped = GridTerminalSystem.GetBlockGroupWithName(TAG);

            if (grouped == null)
            {
                Echo("Group " + TAG + " does not exist.");
                return(false);
            }

            grouped.GetBlocks(allBlocks);

            vents = new List <IMyAirVent>();
            grouped.GetBlocksOfType <IMyAirVent>(vents);
            if (vents.Count == 0)
            {
                Echo("No air vents found");
                return(false);
            }

            setupComplete = true;
            return(true);
        }
示例#13
0
        private void ToggleRepairZone()
        {
            List <IMyShipWelder> repairList = new List <IMyShipWelder>();
            float maxArea = repairMax * repairMax * repairMax;

            GridTerminalSystem.GetBlockGroupWithName(repairGroup).GetBlocksOfType <IMyShipWelder>(repairList, repairUnit => true);

            float repairArea = repairList[0].GetValueFloat("BuildAndRepair.AreaWidth")
                               * repairList[0].GetValueFloat("BuildAndRepair.AreaHeight")
                               * repairList[0].GetValueFloat("BuildAndRepair.AreaDepth");

            foreach (IMyShipWelder repairUnit in repairList)
            {
                if (repairArea >= maxArea)
                {
                    repairUnit.SetValueFloat("BuildAndRepair.AreaWidth", repairWidth);
                    repairUnit.SetValueFloat("BuildAndRepair.AreaHeight", repairHeight);
                    repairUnit.SetValueFloat("BuildAndRepair.AreaDepth", repairDepth);
                }
                else
                {
                    repairUnit.SetValueFloat("BuildAndRepair.AreaWidth", repairMax);
                    repairUnit.SetValueFloat("BuildAndRepair.AreaHeight", repairMax);
                    repairUnit.SetValueFloat("BuildAndRepair.AreaDepth", repairMax);
                }
            }
        }
示例#14
0
        public findStorageCapacity()
        {
            string                  cargoGroupName = "Base Cargo";
            string                  LCDName        = "[MCD] Cargo";
            IMyBlockGroup           cargos         = GridTerminalSystem.GetBlockGroupWithName(cargoGroupName);
            List <IMyTerminalBlock> blocks         = new List <IMyTerminalBlock>();

            cargos.GetBlocks(blocks);
            float capacity = 0;
            float usage    = 0;

            foreach (var block in blocks)
            {
                IMyCargoContainer cargo = block as IMyCargoContainer;
                capacity += (float)cargo.GetInventory(0).MaxVolume;
                usage    += (float)cargo.GetInventory(0).CurrentVolume;
            }
            float          pctUsed = 100.0f * usage / capacity;
            IMyTextSurface lcd     = GridTerminalSystem.GetBlockWithName(LCDName) as IMyTextSurface;

            // If we found that LCD, let's write the graph to it.
            if (lcd != null)
            {
                // Start the display text with a title and our space used in %.
                string displayText = String.Format("Capacity\nOverall: {0}%\n", (int)pctUsed);
                // Build the graph from the top down.
                for (int x = 0; x <= 10; x++)
                {
                    if (pctUsed >= 100 - x * 10)
                    {
                        displayText += "    |    -----    |\n";
                    }
                    else
                    {
                        displayText += "    |              |\n";
                    }
                }
                // Show the result on the LCD.
                //lcd.ShowTextureOnScreen();
                lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                lcd.FontSize    = 2;
                lcd.WriteText(displayText, false);
                //lcd.ShowPublicTextOnScreen();
            }

            /*
             * // Now let's find the warning sign.
             * lcd = GridTerminalSystem.GetBlockWithName(warningName) as IMyTextPanel;
             *
             * // If we found the warning sign, decide whether to have it turned on or off.
             * if (lcd != null) {
             *  // If we've used more than 80% of our cargo, have it turn on. Else, have it turn off.
             *  if (pctUsed > 80) {
             *      lcd.ApplyAction("OnOff_On");
             *  } else {
             *      lcd.ApplyAction("OnOff_Off");
             *  }
             * }
             */
        }
        public Program()
        {
            /*
             *
             * Инициализация блоков управления
             *
             */
            GridTerminalSystem.GetBlockGroupWithName(THRUST_UP).GetBlocks(blocks);
            GetBlockGroup(thrustUp, blocks);

            GridTerminalSystem.GetBlockGroupWithName(THRUST_DOWN).GetBlocks(blocks);
            GetBlockGroup(thrustDown, blocks);

            GridTerminalSystem.GetBlockGroupWithName(THRUST_RIGHT).GetBlocks(blocks);
            GetBlockGroup(thrustRight, blocks);

            GridTerminalSystem.GetBlockGroupWithName(THRUST_LEFT).GetBlocks(blocks);
            GetBlockGroup(thrustLeft, blocks);

            GridTerminalSystem.GetBlockGroupWithName(THRUST_FORWARD).GetBlocks(blocks);
            GetBlockGroup(thrustForward, blocks);

            GridTerminalSystem.GetBlockGroupWithName(THRUST_BACKWARD).GetBlocks(blocks);
            GetBlockGroup(thrustBackward, blocks);

            GridTerminalSystem.GetBlockGroupWithName(ARTIFICIAL_MASS).GetBlocks(blocks);
            GetBlockGroup(artificialMass, blocks);

            cockpit = GridTerminalSystem.GetBlockWithName(COCKPIT) as IMyCockpit;

            Runtime.UpdateFrequency = UpdateFrequency.Update1; // частота обновлений скрипта (60 раз за секунду)
        }
示例#16
0
        public Program()
        {
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
            GridTerminalSystem.GetBlocksOfType <IMyAirVent>(externalVents, b => b.CustomName.Contains(EXTERNAL_VENT_TAG) && b.CubeGrid == Me.CubeGrid);
            GridTerminalSystem.GetBlocksOfType <IMyShipController>(seats, b => b.CubeGrid == Me.CubeGrid);
            GridTerminalSystem.GetBlocksOfType <IMyLandingGear>(gear, b => b.CubeGrid == Me.CubeGrid);

            GridTerminalSystem.GetBlocksOfType <IMyGravityGenerator>(gravGens, b => b.CubeGrid == Me.CubeGrid);

            IMyBlockGroup grp = GridTerminalSystem.GetBlockGroupWithName(INTERIOR_LIGHT_GROUP);

            if (grp != null)
            {
                grp.GetBlocksOfType <IMyLightingBlock>(lights, b => b.CubeGrid == Me.CubeGrid);
            }

            grp = GridTerminalSystem.GetBlockGroupWithName(HYDROGEN_THRUSTER_GROUP);
            if (grp != null)
            {
                grp.GetBlocksOfType <IMyThrust>(h2Thrusters, b => b.CubeGrid == Me.CubeGrid);
            }
            grp = GridTerminalSystem.GetBlockGroupWithName(ATMO_THRUSTER_GROUP);
            if (grp != null)
            {
                grp.GetBlocksOfType <IMyThrust>(atmoThrusters, b => b.CubeGrid == Me.CubeGrid);
            }
            grp = GridTerminalSystem.GetBlockGroupWithName(ION_THRUSTER_GROUP);
            if (grp != null)
            {
                grp.GetBlocksOfType <IMyThrust>(ionThrusters, b => b.CubeGrid == Me.CubeGrid);
            }
        }
示例#17
0
        public void Main()
        {
            var pistonGroup = GridTerminalSystem.GetBlockGroupWithName("PistonsExtend");

            if (pistonGroup == null)
            {
                Echo("ERROR: Group does not exist");
                return;
            }

            var pistons = new List <IMyPistonBase>();

            pistonGroup.GetBlocksOfType(pistons);
            if (pistons.Count == 0)
            {
                Echo("ERROR: Group has no sorters in it");
                return;
            }

            var desiredVelocity = _flip ? SlowSpeed : FastSpeed;

            _flip = !_flip;

            foreach (var p in pistons)
            {
                p.Velocity = p.Velocity < 0 ? -desiredVelocity : desiredVelocity;
            }
        }
示例#18
0
        public void InitLists()
        {
            IMyBlockGroup temp = GridTerminalSystem.GetBlockGroupWithName(solarPanelsGroup);

            if (temp != null)
            {
                temp.GetBlocksOfType(solarPanels);
            }
            else
            {
                solarPanels.Clear();
            }
            temp = GridTerminalSystem.GetBlockGroupWithName(oxygenFarmsGroup);
            if (temp != null)
            {
                temp.GetBlocksOfType(oxygenFarms);
            }
            else
            {
                oxygenFarms.Clear();
            }
            temp = GridTerminalSystem.GetBlockGroupWithName(rotorsGroup);
            if (temp != null)
            {
                temp.GetBlocksOfType(rotors);
            }
            else
            {
                rotors.Clear();
            }
        }
示例#19
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (String.IsNullOrEmpty(argument))
            {
                Echo("No argument!");
                return;
            }
            Echo($"Hey! I received {argument}!");

            IMyBlockGroup myGroup = GridTerminalSystem.GetBlockGroupWithName(argument);
            List <IMyAirtightHangarDoor> myDoors = new List <IMyAirtightHangarDoor>();

            myGroup.GetBlocksOfType(myDoors);

            if (myDoors.Count == 0)
            {
                Echo("No doors on group");
                return;
            }

            foreach (IMyAirtightHangarDoor door in myDoors)
            {
                Echo("Toggled doors!");
                door.ToggleDoor();
            }
        }
示例#20
0
        public Program()
        {
            var pistonGroup = GridTerminalSystem.GetBlockGroupWithName("Drill Rig Pistons");

            pistonGroup.GetBlocksOfType(_pistons);
            Runtime.UpdateFrequency = UpdateFrequency.Update10;
        }
示例#21
0
        public Program()
        {
            groupName              = "invManageGroup"; //all blocks from this group will be managed by the script
            automatic_update       = true;             //if you timer block is in the group the script will run every 100 tics
            max_gravel             = 100000.0f;        // here you are free to change how much gravel you want to keep, you need a connector to be able to remove gravel through this script
            addContainerWhenNeeded = true;

            timerDelay = 8.0f; //8.0f is 8 seconds. Can be changed to whatever.

            currentGravel = 0.0f;

            CargoPrefix = new List <string> {
                "Ore", "Ingot", "Component"
            };
            setupRelativeType();

            group = GridTerminalSystem.GetBlockGroupWithName(groupName);
            if (group == null)
            {
                Echo("No group found, returning");
                Echo("Once you've added a group recompile script and run again");
                return;
            }
            updateBlocks();

            if (automatic_update && timer != null)
            {
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }
            else
            {
                Runtime.UpdateFrequency = UpdateFrequency.Once;
            }
        }
示例#22
0
// @formatter:on

        public void Main(string argument)
        {
            var pistonGroup = GridTerminalSystem.GetBlockGroupWithName(argument);

            if (pistonGroup == null)
            {
                Echo($"ERROR: Group '{argument}' does not exist");
                return;
            }

            var sorters = new List <IMyConveyorSorter>();

            pistonGroup.GetBlocksOfType(sorters);
            if (sorters.Count == 0)
            {
                Echo($"ERROR: Group '{argument}' has no sorters in it");
                return;
            }

            var filterList = new List <MyInventoryItemFilter>
            {
                new MyInventoryItemFilter("MyObjectBuilder_Ore/Stone", false),
                new MyInventoryItemFilter("MyObjectBuilder_Ore/Ice", false),
            };

            foreach (var s in sorters)
            {
                s.DrainAll = true;
                s.SetFilter(MyConveyorSorterMode.Whitelist, filterList);
            }

            Echo($"Configured {sorters.Count} sorters");
        }
        private void initBlock(string name)
        {
            Echo("initBlock() " + name);
            var block = GridTerminalSystem.GetBlockWithName(name);

            if (block != null)
            {
                if (block is IMyTextPanel)
                {
                    lcd = block as IMyTextPanel;
                }
            }
            else
            {
                var group = GridTerminalSystem.GetBlockGroupWithName(name);
                if (group != null)
                {
                    if (group is IMyBlockGroup)
                    {
                        batteryList.Clear();
                        (group as IMyBlockGroup).GetBlocksOfType <IMyBatteryBlock>(batteryList);
                    }
                }
            }
        }
示例#24
0
        public Program()
        {
            // The constructor, called only once every session and
            // always before any other method is called. Use it to
            // initialize your script.
            //
            // The constructor is optional and can be removed if not
            // needed.
            //
            // It's recommended to set Runtime.UpdateFrequency
            // here, which will allow your script to run itself without a
            // timer block.
            Runtime.UpdateFrequency = UpdateFrequency.Update10;
            MyIniParseResult result;

            if (!ini.TryParse(Me.CustomData, out result))
            {
                throw new Exception(result.ToString());
            }
            string displayName = ini.Get("config", "DisplayName").ToString();

            gravel_group_name = ini.Get("config", "GroupName").ToString();
            gravel_limit      = ini.Get("config", "GravelLimit").ToInt32();

            panel = GridTerminalSystem.GetBlockWithName(displayName) as IMyTextPanel;
            Utilities.setupDisplay(panel as IMyTextPanel);
            panel.WriteText("F*****G SHITTY LCD", false);
            Echo(gravel_group_name);
            gravel_shitter_group = GridTerminalSystem.GetBlockGroupWithName(gravel_group_name);
            gravel_shitter_group.GetBlocks(gravel_shitters);
        }
示例#25
0
        private void GetBlocks()
        {
            string        blockGroupName = configReader.Get <string>("blockGroupName");
            IMyBlockGroup blockGroup     = GridTerminalSystem.GetBlockGroupWithName(blockGroupName);

            List <IMyShipController> controllers = new List <IMyShipController>();

            blockGroup.GetBlocksOfType <IMyShipController>(controllers);
            if (controllers.Count == 0)
            {
                throw new Exception("Error: " + blockGroupName + " does not contain a cockpit or remote control block.");
            }
            cockpit = controllers[0];

            List <IMyTextPanel> textPanels = new List <IMyTextPanel>();

            blockGroup.GetBlocksOfType <IMyTextPanel>(textPanels);
            if (textPanels.Count > 0)
            {
                textPanel          = textPanels[0];
                textPanel.Font     = "Monospace";
                textPanel.FontSize = 1.0f;
                textPanel.ShowPublicTextOnScreen();
            }

            blockGroup.GetBlocksOfType <IMyGyro>(gyros);
            if (gyros.Count == 0)
            {
                throw new Exception("Error: " + blockGroupName + " does not contain any gyroscopes.");
            }
        }
示例#26
0
        public void Init()
        {
            IMyBlockGroup blocks = GridTerminalSystem.GetBlockGroupWithName(ProjectorGroup);

            blocks.GetBlocksOfType <IMyProjector>(_Projectors);
            blocks.GetBlocksOfType <IMyTextPanel>(_LCDPanels);
            _InfoLCD = null;
            _ListLCD = null;
            _DescLCD = null;
            foreach (IMyTextPanel lcd in _LCDPanels)
            {
                if (lcd.ContentType != ContentType.TEXT_AND_IMAGE)
                {
                    lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                }
                if (lcd.DisplayNameText.Contains(InfoLCDFilter))
                {
                    _InfoLCD = lcd;
                }
                else if (lcd.DisplayNameText.Contains(DescriptionLCDFilter))
                {
                    _DescLCD = lcd;
                }
                else if (lcd.DisplayNameText.Contains(ListLCDFilter))
                {
                    _ListLCD = lcd;
                }
            }
        }
 public Program()
 {
     // The constructor, called only once every session and
     // always before any other method is called. Use it to
     // initialize your script.
     //
     // The constructor is optional and can be removed if not
     // needed.
     //
     // It's recommended to set Runtime.UpdateFrequency
     // here, which will allow your script to run itself without a
     // timer block.
     Runtime.UpdateFrequency = UpdateFrequency.Update1;
     g         = GridTerminalSystem.GetBlockWithName("Gyro") as IMyGyro;
     sc        = GridTerminalSystem.GetBlockWithName("Cockpit") as IMyShipController;
     lcd       = GridTerminalSystem.GetBlockWithName("LCD") as IMyTextPanel;
     thrusters = new List <IMyThrust>();
     GridTerminalSystem.GetBlockGroupWithName("Thrusters").GetBlocksOfType <IMyThrust>(thrusters);
     hDamp        = false;
     manualAlt    = true;
     vDamp        = false;
     targAltitude = GetAltitude();
     mass         = sc.CalculateShipMass().PhysicalMass;
     curSpeed     = 0;
     lastHeading  = sc.WorldMatrix.Forward;
 }
示例#28
0
        public Program()
        {
            cockpit = GridTerminalSystem.GetBlockWithName("Cockpit") as IMyCockpit;
            GridTerminalSystem.GetBlockGroupWithName("Gyros").GetBlocks(gyros);

            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
示例#29
0
        public Program()
        {
            base_prgblk  = GridTerminalSystem.GetBlockWithName(base_prgblk_name) as IMyProgrammableBlock;
            drill_drills = GridTerminalSystem.GetBlockGroupWithName(drill_drills_name);
            drill_rotor  = GridTerminalSystem.GetBlockGroupWithName(drill_rotor_name);
            drill_landing_gears_pistons = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_pistons_name);
            drill_landing_gears         = GridTerminalSystem.GetBlockGroupWithName(drill_landing_gears_name);
            drill_pistons     = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name);
            text_panel_status = GridTerminalSystem.GetBlockWithName(text_panel_status_name) as IMyTextPanel;
            drill_pistons     = GridTerminalSystem.GetBlockGroupWithName(drill_pistons_name);
            drill_connector   = GridTerminalSystem.GetBlockWithName(drill_connector_name) as IMyShipConnector;

            //read stored config
            if (Storage.Length != 0)
            {
                string[] stored_config = Storage.Split('\n');
                {
                    read_stored_settings(stored_config);
                }
            }

            if (drill_status == "")
            {
                drill_status = "stopped";
                write_settings();
            }

            drill_connector_status  = drill_connector.Status.ToString();
            Runtime.UpdateFrequency = UpdateFrequency.Update100;
            verify_availability();
            write_settings();
        }
示例#30
0
        void Init()
        {
            GridTerminalSystem.GetBlockGroupWithName(designator + acceleratorGroupName)?.GetBlocksOfType <IMyMotorStator>(accelerators);
            if (!accelerators.Any())
            {
                throw new Exception($"Error: No rotors in group {designator}{acceleratorGroupName}");
            }

            GridTerminalSystem.GetBlockGroupWithName(designator + generatorGroupName)?.GetBlocksOfType <IMyMotorStator>(generators);
            if (!generators.Any())
            {
                throw new Exception($"Error: No rotors in group {designator}{generatorGroupName}");
            }

            for (int i = 0; i < accelerators.Count; i++)
            {
                if (safeMode)
                {
                    if (accelerators[i].CubeGrid.GridSizeEnum == VRage.Game.MyCubeSize.Small)
                    {
                        smallGrid = true;
                    }
                }
                accelerators[i].SetValue("Displacement", ExtensionDistance);
            }
            initialised = true;
        }