예제 #1
0
        private void stopDrill()
        {
            var blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(stop, blocks);
            if (blocks.Count == 0)
            {
                throw new Exception("Could not find block with name: '" + stop + "'");
            }

            var ejectorEnum = ejectors.GetEnumerator();

            while (ejectorEnum.MoveNext())
            {
                var ejector = ejectorEnum.Current;
                if (ejector.ThrowOut)
                {
                    ejector.GetActionWithName("ThrowOut").Apply(ejector);
                }
            }

            var block = blocks[0];

            block.SetCustomName(block.CustomName + "," + "full");
            block.ApplyAction("Run");
        }
 void checkStock(String item, float qty)
 {
     if (minimums.ContainsKey(item))
     {
         List <IMyTerminalBlock> assemblerList = new List <IMyTerminalBlock>();
         GridTerminalSystem.SearchBlocksOfName(item + " Assembler", assemblerList);
         if (minimums[item] > qty)
         {
             WriteDebug("{0}: {1} > {2}", item, minimums[item], qty);
             for (int i = 0; i < assemblerList.Count; i++)
             {
                 if (assemblerList[i] is IMyAssembler)
                 {
                     ((IMyAssembler)assemblerList[i]).GetActionWithName("OnOff_On").Apply(((IMyAssembler)assemblerList[i]));
                 }
             }
         }
         else
         {
             WriteDebug("{0}: {1} <= {2}", item, minimums[item], qty);
             for (int i = 0; i < assemblerList.Count; i++)
             {
                 if (assemblerList[i] is IMyAssembler)
                 {
                     ((IMyAssembler)assemblerList[i]).GetActionWithName("OnOff_Off").Apply(((IMyAssembler)assemblerList[i]));
                 }
             }
         }
     }
 }
예제 #3
0
        public void Setup()
        {
            // Cockpit
            List <IMyTerminalBlock> cockpitListReferences = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(CockpitTag, cockpitListReferences);
            if (cockpitListReferences.Count == 0)
            {
                throw new Exception("No cockpit found! Check the naming tag.");
            }

            CockpitBlock   = (IMyShipController)cockpitListReferences[0];
            ReferenceBlock = cockpitListReferences[0];

            // Antenna
            List <IMyTerminalBlock> antennaListReferences = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(AntennaTag, antennaListReferences);

            if (antennaListReferences.Count == 0)
            {
                throw new Exception("No ILS Receiver Antenna! Check naming tag.");
            }

            Antenna = (IMyRadioAntenna)antennaListReferences[0];
            IGC.RegisterBroadcastListener(ILSAntennaChannel);
            IGC.RegisterBroadcastListener(VORAntennaChannel);
            IGC.RegisterBroadcastListener(NDBAntennaChannel);


            // Mark setup as completed.
            SetupComplete = true;
            Echo("Setup complete.");
        }
        // Method for finding blocks by names
        List <IMyTerminalBlock> SearchBlocksByName(string blockName)
        {
            var blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(blockName, blocks);
            return(blocks);
        }
예제 #5
0
        string BlockInit()
        {
            string sInitResults = "";

            gpsCenter = null;

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

            GridTerminalSystem.SearchBlocksOfName(sGPSCenter, centerSearch);
            if (centerSearch.Count == 0)
            {
                GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(centerSearch, localGridFilter);
                foreach (var b in centerSearch)
                {
                    if (b.CustomName.Contains("[NAV]") || b.CustomData.Contains("[NAV]"))
                    {
                        gpsCenter = b;
                    }
                    else if (b.CustomName.Contains("[!NAV]") || b.CustomData.Contains("[!NAV]"))
                    {
                        continue; // don't use this one.
                    }
                    sInitResults = "R";
                    gpsCenter    = b;
                    break;
                }
                if (gpsCenter == null)
                {
                    GridTerminalSystem.GetBlocksOfType <IMyShipController>(centerSearch, localGridFilter);
                    if (centerSearch.Count == 0)
                    {
                        sInitResults += "!!NO Controller";
                        return(sInitResults);
                    }
                    else
                    {
                        sInitResults += "S";
                        gpsCenter     = centerSearch[0];
                    }
                }
            }
            else
            {
                sInitResults += "N";
                gpsCenter     = centerSearch[0];
            }

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

            blocks = GetBlocksContains <IMyTextPanel>("[GPS]");
            if (blocks.Count > 0)
            {
                gpsPanel = blocks[0] as IMyTextPanel;
            }
            if (gpsCenter == null)
            {
                Echo("ERROR: No control block found!");
            }
            return(sInitResults);
        }
 /// <summary>
 /// Populates the trackedInventories list
 /// </summary>
 private void GetTrackedInventories()
 {
     trackedInventories = new List <IMyInventory>();
     tempBlockList      = new List <IMyTerminalBlock>();
     if (!trackAll)
     {
         GridTerminalSystem.SearchBlocksOfName(itemTrackTag, tempBlockList);
     }
     else
     {
         GridTerminalSystem.GetBlocks(tempBlockList);
     }
     for (int blockIndex = 0; blockIndex < tempBlockList.Count; blockIndex++)
     {
         var block = tempBlockList[blockIndex];
         if (!block.HasInventory)
         {
             continue;
         }
         for (int invIndex = 0; invIndex < block.InventoryCount; invIndex++)
         {
             var inventory = block.GetInventory(invIndex);
             trackedInventories.Add(inventory);
         }
     }
 }
예제 #7
0
        public Program()

        {
            // It's recommended to set RuntimeInfo.UpdateFrequency
            // Replace the Echo
            Echo = this.EchoToLCD;

            // Fetch a log text panel
            this._logOutput = GridTerminalSystem.GetBlockWithName("Airlock LCD") as IMyTextPanel;

            this.innerDoors = new List <IMyTerminalBlock>();
            this.outerDoors = new List <IMyTerminalBlock>();

            this.innerDoorLights = new List <IMyTerminalBlock>();
            this.outerDoorLights = new List <IMyTerminalBlock>();

            //this.mainVent = GridTerminalSystem.GetBlockWithName("Airlock Air Vent Main") as IMyAirVent;
            this.purgeVent = GridTerminalSystem.GetBlockWithName("Airlock Air Vent Purge") as IMyAirVent;

            GridTerminalSystem.SearchBlocksOfName("Airlock Inner Door", this.innerDoors, door => door is IMyDoor);
            GridTerminalSystem.SearchBlocksOfName("Airlock Outer Door", this.outerDoors, door => door is IMyAirtightHangarDoor);

            GridTerminalSystem.SearchBlocksOfName("Airlock Inner Door Light", this.innerDoorLights, door => door is IMyInteriorLight);
            GridTerminalSystem.SearchBlocksOfName("Airlock Outer Door Light", this.outerDoorLights, door => door is IMyInteriorLight);

            this.airlockState  = AirlockState.Unknown;
            this.buttonPressed = ButtonPressed.Unknown;
            //Echo(innerDoors.Count.ToString());

            var x = this.purgeVent.CanPressurize;
        }
예제 #8
0
    //Создаёт лист блоков в имени которых содержится текст из переменной.
    public List <IMyTerminalBlock> FindBlockByPartOfName(string blockName)
    {
        List <IMyTerminalBlock> blockList = new List <IMyTerminalBlock>();

        //GridTerminalSystem.GetBlocksOfType<IMyTerminalBlock>(blockList);
        GridTerminalSystem.SearchBlocksOfName(blockName, blockList);
        return(blockList);
    }
        //Components list



        /*==#=====#====#=====#=====#=====#=====#=====#====#=====#=====#=====#=====#=====#====#===================*/
        //dont edit unless you know what you are doing !//
        /*==#=====#====#=====#=====#=====#=====#=====#====#=====#=====#=====#=====#=====#====#===================*/

        //Methods//

        public List <IMyTerminalBlock> MultiBlockGet(string NAME)
        {
            List <IMyTerminalBlock> output = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(NAME, output);

            return(output);
        }
예제 #10
0
        public IMyTerminalBlock GetBlockWithNameOnGrid(string name)
        {
            List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(name, blocks, x => x.CubeGrid == Me.CubeGrid);

            return(blocks[0]);
        }
예제 #11
0
 public void Main(string args)
 {
     //IMyTextPanel myTextPanel = GridTerminalSystem.GetBlockWithName("LCD00") as IMyTextPanel;
     GridTerminalSystem.SearchBlocksOfName("LCD00", blockList);
     foreach (IMyTextPanel panel in blockList)
     {
         panel.WritePublicText("222");
     }
 }
예제 #12
0
        List <IMyTerminalBlock> GetBlocksWithName <T>(string name, int matchType = 0) where T : class, IMyTerminalBlock
        {
            List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(name, blocks);

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

            for (int i = 0; i < blocks.Count; i++)
            {
                if (matchType > 0)
                {
                    bool isMatch = false;

                    switch (matchType)
                    {
                    case 1:
                        if (blocks[i].CustomName.StartsWith(name, StringComparison.OrdinalIgnoreCase))
                        {
                            isMatch = true;
                        }
                        break;

                    case 2:
                        if (blocks[i].CustomName.EndsWith(name, StringComparison.OrdinalIgnoreCase))
                        {
                            isMatch = true;
                        }
                        break;

                    case 3:
                        if (blocks[i].CustomName.Equals(name, StringComparison.OrdinalIgnoreCase))
                        {
                            isMatch = true;
                        }
                        break;

                    default:
                        isMatch = true;
                        break;
                    }

                    if (!isMatch)
                    {
                        continue;
                    }
                }

                IMyTerminalBlock block = blocks[i] as T;
                if (block != null)
                {
                    filteredBlocks.Add(block);
                }
            }

            return(filteredBlocks);
        }
예제 #13
0
        void Debug(String message)
        {
            var list = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(debugName, list);
            if (list.Count > 0)
            {
                list[0].SetCustomName(debugName + ":\n\r" + message);
            }
        }
예제 #14
0
        void Output(String message, bool append = false)
        {
            var list = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(OutputString, list);
            if (list.Count > 0)
            {
                list[0].SetCustomName(append ? list[0].CustomName + message : message);
            }
        }
예제 #15
0
        public void Setup()
        {
            LCDScreens = new List <IMyTerminalBlock>();
            GridTerminalSystem.SearchBlocksOfName(ScreenTag, LCDScreens);
            if (LCDScreens.Count == 0)
            {
                throw new Exception("No Main LCD found!");
            }

            SetupIsCompleted = true;
        }
예제 #16
0
        List <T> SearchBlocksWithName <T>(string name) where T : class
        {
            var result = new List <T>();
            var blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(name, blocks);

            blocks.ForEach(block => result.Add((T)block));

            return(result);
        }
 /// <summary>
 /// Populates a list of blocks of type T from any blocks that have a specific tag
 /// </summary>
 private void PopulateTaggedList <T>(List <T> outList, string blockTag)
 {
     tempBlockList = new List <IMyTerminalBlock>();
     outList.Clear();
     GridTerminalSystem.SearchBlocksOfName(blockTag, tempBlockList);
     for (int i = 0; i < tempBlockList.Count; i++)
     {
         T block = (T)tempBlockList[i];
         outList.Add(block);
     }
 }
예제 #18
0
        public IMyRadioAntenna FindAntennaBlock()
        {
            List <IMyTerminalBlock> AntennaListReferences = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(AntennaTag, AntennaListReferences);
            if (AntennaListReferences.Count == 0)
            {
                throw new Exception("No antenna found! Check the naming tag.");
            }

            return((IMyRadioAntenna)AntennaListReferences[0]);
        }
예제 #19
0
//        IMyTextPanel gpsPanel = null;

        string BlockInit()
        {
            string sInitResults = "";

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

            GridTerminalSystem.SearchBlocksOfName(sGPSCenter, centerSearch, (x1 => x1.CubeGrid == Me.CubeGrid));
            if (centerSearch.Count == 0)
            {
                centerSearch = GetBlocksContains <IMyRemoteControl>("[NAV]");
                if (centerSearch.Count == 0)
                {
                    GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(centerSearch, (x1 => x1.CubeGrid == Me.CubeGrid));
                    if (centerSearch.Count == 0)
                    {
                        GridTerminalSystem.GetBlocksOfType <IMyCockpit>(centerSearch, localGridFilter);
                        //                GridTerminalSystem.GetBlocksOfType<IMyShipController>(centerSearch, localGridFilter);
                        int i = 0;
                        for (; i < centerSearch.Count; i++)
                        {
                            Echo("Checking Controller:" + centerSearch[i].CustomName);
                            if (centerSearch[i] is IMyCryoChamber)
                            {
                                continue;
                            }
                            break;
                        }
                        if (i > centerSearch.Count)
                        {
                            sInitResults += "!!NO valid Controller";
                            Echo("No Controller found");
                        }
                        else
                        {
                            sInitResults += "S";
                            Echo("Using good ship Controller: " + centerSearch[i].CustomName);
                        }
                    }
                    else
                    {
                        sInitResults += "R";
                        Echo("Using First Remote control found: " + centerSearch[0].CustomName);
                    }
                }
            }
            else
            {
                sInitResults += "N";
                Echo("Using Named: " + centerSearch[0].CustomName);
            }

            return(sInitResults);
        }
예제 #20
0
        string BlockInit()
        {
            string sInitResults = "";

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

            GridTerminalSystem.SearchBlocksOfName(sGPSCenter, centerSearch);
            if (centerSearch.Count == 0)
            {
                centerSearch = GetBlocksContains <IMyRemoteControl>("[NAV]");
                if (centerSearch.Count == 0)
                {
                    GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(centerSearch, localGridFilter);
                    if (centerSearch.Count == 0)
                    {
                        GridTerminalSystem.GetBlocksOfType <IMyShipController>(centerSearch, localGridFilter);
                        if (centerSearch.Count == 0)
                        {
                            sInitResults += "!!NO Controller";
                            return(sInitResults);
                        }
                        else
                        {
                            sInitResults += "S";
                        }
                    }
                    else
                    {
                        sInitResults += "R";
                    }
                }
            }
            else
            {
                sInitResults += "N";
            }
            gpsCenter = centerSearch[0];

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

            blocks = GetBlocksContains <IMyTextPanel>("[GPS]");
            if (blocks.Count > 0)
            {
                gpsPanel = blocks[0] as IMyTextPanel;
            }

            if (gpsCenter == null)
            {
                Echo("ERROR: No control block found!");
            }

            return(sInitResults);
        }
예제 #21
0
        public void FindCockpitBlock()
        {
            List <IMyTerminalBlock> cockpitListReferences = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(CockpitTag, cockpitListReferences);
            if (cockpitListReferences.Count == 0)
            {
                throw new Exception("No cockpit found! Check the naming tag.");
            }

            CockpitBlock = (IMyShipController)cockpitListReferences[0];
        }
예제 #22
0
        List <T> SearchBlocksWithName <T>(string name) where T : class
        {
            var result = new List <T>();
            var blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(name, blocks);

            for (var i = 0; i < blocks.Count; i++)
            {
                result.Add((T)blocks[i]);
            }

            return(result);
        }
예제 #23
0
        //To put your code in a PB copy from this comment...
        // Find working block with name
        public Type FindBlock <Type>(string name) where Type : class, IMyTerminalBlock
        {
            List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(name, blocks);
            for (var i = 0; i < blocks.Count; i++)
            {
                if (blocks[i].IsWorking)
                {
                    return(blocks[i] as Type);
                }
            }
            return(null);
        }
        public CentrifugeScript()
        {
            _centrifuges = new List <Centrifuge>();
            _work        = new List <IMyTerminalBlock>();
            _containers  = new List <IMyTerminalBlock>();

            _debugPanel = GridTerminalSystem.GetBlockWithName(LCDNAME) as IMyTextPanel;
            if (_debugPanel != null)
            {
                _debugPanel.ContentType = ContentType.TEXT_AND_IMAGE;
            }

            //Add container blocks
            GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(_work);
            _containers.AddRange(_work);
            _work.Clear();

            //Add refineries
            GridTerminalSystem.GetBlocksOfType <IMyRefinery>(_work);
            _containers.AddRange(_work);

            // Find the centrifuges to autofeed
            List <IMyTerminalBlock> tempList = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(CENTRIFUGENAME, tempList);

            bool isUnique = false;

            foreach (var cent in tempList)
            {
                isUnique = true;
                foreach (var container in _containers)
                {
                    if (cent.EntityId == container.EntityId)
                    {
                        isUnique = false; break;
                    }
                }

                if (isUnique)
                {
                    _centrifuges.Add(new Centrifuge(cent));
                }
            }

            if (_centrifuges.Count < 1)
            {
                Print("No Centrifuges found!");
            }
        }
예제 #25
0
    public InvSorter()
    {
        List <IMyTerminalBlock> TermBlks;

        // Add Main and Ore Cargo Container
        OreInv  = GetInvWithName(ore_cargo_name, 0);
        MainInv = GetInvWithName(main_cargo_name, 0);

        // Check that we have indeed found the Ore and Main Cargo holds
        if (OreInv == null || MainInv == null)
        {
            pr("Error: Could not find either Ore or Main cargo holds");
            pr("Inventory Management: Error");
            return;
        }

        // Add Main and Ore Cargo Containers
        OtherInv.Add(OreInv);
        OtherInv.Add(MainInv);

        // Get all access ports
        TermBlks = new List <IMyTerminalBlock>();
        GridTerminalSystem.SearchBlocksOfName("Cargo Access", TermBlks);
        for (int i = 0; i < TermBlks.Count; i++)
        {
            OtherInv.Add(TermBlks[i].GetInventory(0));
        }

        // Get connected miner cargo
        TermBlks = new List <IMyTerminalBlock>();
        GridTerminalSystem.SearchBlocksOfName("Miner Cargo", TermBlks);
        for (int i = 0; i < TermBlks.Count; i++)
        {
            OtherInv.Add(TermBlks[i].GetInventory(0));
        }

        // Add various other inventories to be sorted
        AddInvOfType <IMyRefinery>(1);
        AddInvOfType <IMyAssembler>(1);
        AddInvOfType <IMyShipConnector>(0);

        // Send the stuff to the right places
        for (int i = 0; i < OtherInv.Count; i++)
        {
            SortPeriphInv(OtherInv[i]);
        }

        pr("Inventory Management: Online");
    }
        public void WriteToTextPanel(string input)
        {
            List <IMyTerminalBlock> lcds = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(_outputLCD, lcds, b => b.CubeGrid == Me.CubeGrid);

            if (lcds.Count == 0)
            {
                Echo("\nNo LCD with name '" + _outputLCD + "' found.\nCheck the name.");
            }
            foreach (IMyTextPanel lcd in lcds)
            {
                lcd.WriteText(input);
            }
        }
예제 #27
0
    public LightSetter()
    {
        List <IMyTerminalBlock> lights = new List <IMyTerminalBlock>();

        GridTerminalSystem.SearchBlocksOfName("Interior Light", lights);
        Color c = new Color(244, 255, 250, 255);

        for (int i = 0; i < lights.Count; i++)
        {
            lights[i].SetValueFloat("Intensity", 0.5f);
            lights[i].SetValueFloat("Radius", 9.0f);
            lights[i].SetValueFloat("Falloff", 2.0f);
            lights[i].SetValue("Color", c);
        }
    }
예제 #28
0
        public void Main(string argument)
        {
            // need the name of the
            // calling keypad, so need a split here

            if (argument == "")
            {
                // no arguments, scan for keypads

                ScanForKeypads(GridTerminalSystem);

                //then run update of all registered keypads.
                var keypadEnum = keypads.GetEnumerator();
                while (keypadEnum.MoveNext())
                {
                    Keypad current = keypadEnum.Current.Value;
                    current.Update();
                }
            }
            else
            {
                // Argument specified, so let's find the specified
                // keypad and run the command

                // split the args on spaces... maybe.
                string[] args       = argument.Split(new[] { ' ' }, 2);
                string   cmd        = args[0];
                string   keypadName = args[1];

                // Find the keypad with this name, first search for the bock
                List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();
                GridTerminalSystem.SearchBlocksOfName(keypadName, blocks, null);
                Echo("Found: " + blocks.Count.ToString());
                Echo("   with name matching: " + keypadName);
                if (blocks.Count == 1)
                {
                    if (keypads.ContainsKey(blocks[0].CustomName))
                    {
                        // found a keypad.
                        keypads[blocks[0].CustomName].Clicked(cmd);
                    }
                }
                else
                {
                    Echo("Search returned multiple results. Invalid Keypad Name");
                }
            }
        }
        void Main()
        {
            var list = new List <IMyTerminalBlock>();

            GridTerminalSystem.SearchBlocksOfName(InputString, list);
            if (list.Count == 0)
            {
                throw new Exception("waah"); // Exception
            }
            else
            {
                var block = list[0];
                block.SetCustomName(InputString + Command);
                block.ApplyAction("Run");
            }
        }
        public void Setup()
        {
            _control = GridTerminalSystem.GetBlockWithName(_cockpit) as IMyShipController;

            var naming = new string[3, 2] {
                { "FL", "FR" },
                { "ML", "MR" },
                { "BL", "BR" }
            };

            _motors   = new List <IMyMotorStator> [naming.GetLength(1), naming.GetLength(0)];
            _steering = new List <IMyMotorStator> [naming.GetLength(1)];

            _brakes = new List <IMyPistonBase> [naming.GetLength(1), naming.GetLength(0)];

            List <IMyTerminalBlock> blocks;

            for (int i = 0; i < _motors.GetLength(0); i++)
            {
                for (int j = 0; j < _motors.GetLength(1); j++)
                {
                    blocks = new List <IMyTerminalBlock>();
                    GridTerminalSystem.SearchBlocksOfName("Motor " + naming[j, i], blocks, block => block is IMyMotorStator);
                    _motors[i, j] = new List <IMyMotorStator>();
                    foreach (var block in blocks)
                    {
                        _motors[i, j].Add(block as IMyMotorStator);
                    }

                    blocks = new List <IMyTerminalBlock>();
                    GridTerminalSystem.SearchBlocksOfName("Brake " + naming[j, i], blocks, block => block is IMyPistonBase);
                    _brakes[i, j] = new List <IMyPistonBase>();
                    foreach (var block in blocks)
                    {
                        _brakes[i, j].Add(block as IMyPistonBase);
                    }
                }

                blocks = new List <IMyTerminalBlock>();
                GridTerminalSystem.SearchBlocksOfName("Rotor Steering " + naming[0, i], blocks, block => block is IMyMotorStator);
                _steering[i] = new List <IMyMotorStator>();
                foreach (var block in blocks)
                {
                    _steering[i].Add(block as IMyMotorStator);
                }
            }
        }