public void Main(string argument, UpdateType updateSource) { UpdateInv(); if (ComputerCount < compAmount) { Assembler.AddQueueItem(MyDefinitionId.Parse("MyObjectBuilder_BlueprintDefinition/ComputerComponent"), compAmount - ComputerCount); } if (ConstructionCount < constructAmount) { Assembler.AddQueueItem(MyDefinitionId.Parse("MyObjectBuilder_BlueprintDefinition/ConstructionComponent"), constructAmount - ConstructionCount); } if (SteelPlateCount < steelAmount) { Assembler.AddQueueItem(MyDefinitionId.Parse("MyObjectBuilder_BlueprintDefinition/SteelPlate"), steelAmount - SteelPlateCount); } if (MotorCount < motorAmount) { Assembler.AddQueueItem(MyDefinitionId.Parse("MyObjectBuilder_BlueprintDefinition/MotorComponent"), motorAmount - MotorCount); } if (Assembler.GetInventory(1).IsItemAt(0)) { Assembler.GetInventory(1).TransferItemTo(CompContainer.GetInventory(0), Assembler.GetInventory(1).GetItemAt(0).Value); } }
public static MyFixedPoint MoveItem(IMyCargoContainer from, IMyCargoContainer to, string type, MyFixedPoint?amount) { MyFixedPoint amountmoved = new MyFixedPoint(); MyInventoryItem?item; bool moved; for (int i = from.GetInventory(0).ItemCount; i >= 0; i--) { item = from.GetInventory(0).GetItemAt(i); if (item.HasValue && item.Value.Type.SubtypeId == type) { MyFixedPoint amounttomove = amount.HasValue ? MyFixedPoint.Min(amount.Value - amountmoved, item.Value.Amount) : item.Value.Amount; moved = to.GetInventory(0).TransferItemFrom(from.GetInventory(0), item.Value, amounttomove); if (!moved) { return(amountmoved); } amountmoved += amounttomove; if (amountmoved >= amount) { return(amountmoved); } } } return(amountmoved); }
// // http://steamcommunity.com/sharedfiles/filedetails/?id=360966557 // https://forum.keenswh.com/threads/pb-scripting-guide-how-to-use-self-updating.7398267/ // //---------------------------------------------------------------------------------------------------------------------- // Kopioitava koodi //---------------------------------------------------------------------------------------------------------------------- void Main() { // ------------ Auto update --------------- Runtime.UpdateFrequency = UpdateFrequency.Update10; // ------------ Definitions --------------- IMyTextPanel naytto1 = GridTerminalSystem.GetBlockWithName("Infoscreen") as IMyTextPanel; IMyCargoContainer cargo1 = GridTerminalSystem.GetBlockWithName("Hitsi cargo 1") as IMyCargoContainer; // ------------ Logic --------------- // --- Cargo 1 usage --- float usedVolume1 = 0.0f; float maxVolume1 = 0.0f; usedVolume1 = (float)cargo1.GetInventory(0).CurrentVolume; maxVolume1 += (float)cargo1.GetInventory(0).MaxVolume; float pctUsed1 = 100.0f * usedVolume1 / maxVolume1; // ------------ Screen writing --------------- naytto1.WritePublicText("\n\n\n\n Cargo-1 käytössä: " + (int)pctUsed1 + "%", false); naytto1.ShowPublicTextOnScreen(); }
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"); * } * } */ }
/// <summary> /// Sorter cache /// </summary> /// <returns></returns> public Cargo EnableCache() { // nutny blok Cache = Instance.GetListByName <IMyCargoContainer>("_Cache", true).First(); // definice List <MyInventoryItem> components = new List <MyInventoryItem>(); List <MyInventoryItem> cache = new List <MyInventoryItem>(); MyFixedPoint amount = 0; Dictionary <string, MyFixedPoint> cached = new Dictionary <string, MyFixedPoint>(); // nacteni polozek Component.GetInventory(0).GetItems(components); Cache.GetInventory(0).GetItems(cache); // premapovani nakesovanych polozek foreach (MyInventoryItem item in cache) { cached.Add(item.Type.SubtypeId, item.Amount); } // presun polozek for (int i = components.Count - 1; i >= 0; i--) { // definice string localType = components[i].Type.SubtypeId; MyFixedPoint localAmount = components[i].Amount; // pokud se nejedna o nezadouci polozku a zaroven u v kesi neexistuje if (Constants.ComponentsToCache.Contains(localType)) { if (cached.ContainsKey(localType)) { amount = Constants.SorterCache - cached[localType]; } else { // vytvoreni polozky cached.Add(localType, 0); // urceni mnozstvi if (localAmount < Constants.SorterCache) { amount = localAmount; } else { amount = Constants.SorterCache; } } // presun do serteru if (amount > 0) { cached[localType] += amount; Component.GetInventory(0).TransferItemTo(Cache.GetInventory(0), i, null, true, amount); } } } // fluent return(this); }
public void ClearAssemblerQueue(IMyAssembler AssemblerQueue, IMyCargoContainer WelderContainer, IMyCargoContainer CargoContainers) //This clear queue in assebler and remove items from welding ship container { AssemblerQueue.ClearQueue(); for (int i = WelderContainer.GetInventory(0).ItemCount - 1; i >= 0; i--) { if (CargoContainers.GetInventory(0).CanItemsBeAdded(WelderContainer.GetInventory(0).GetItemAt(i).Value.Amount, WelderContainer.GetInventory(0).GetItemAt(i).Value.Type)) { WelderContainer.GetInventory(0).TransferItemTo(CargoContainers.GetInventory(0), WelderContainer.GetInventory(0).GetItemAt(i).Value); } } }
public void PrintInventory(IMyCargoContainer Container, IMyTextPanel LCD) { string output = ""; for (int i = 0; i < Container.GetInventory(0).ItemCount; i++) { output += Container.GetInventory(0).GetItemAt(i).Value.Amount + " " + Container.GetInventory(0).GetItemAt(i).Value.Type.SubtypeId + "\n"; } LCD.ContentType = ContentType.TEXT_AND_IMAGE; LCD.WriteText(output); }
void DoRefine() { var destBoxInventory = _materialCargo.GetInventory(); var remainAmount = _oreToRefine; // destBoxInventory.TransferItemFrom }
private float GetCargoSpace(List <IMyTerminalBlock> cargoContainers = null) { float result = 0; int count = 0; var source = cargoContainers ?? new List <IMyTerminalBlock>(); if (cargoContainers == null) { GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(source); } for (int i = 0; i < source.Count; i++) { IMyCargoContainer cargoContainer = source[i] as IMyCargoContainer; if (cargoContainer == null) { continue; } IMyInventory inventory = cargoContainer.GetInventory(0); float currentVolume = inventory.CurrentVolume.RawValue; float maxVolume = inventory.MaxVolume.RawValue; result += currentVolume / maxVolume; DebugString.AppendLine(string.Format("{0} / {1} = {2}", currentVolume, maxVolume, currentVolume / maxVolume)); count++; } return(count != 0 ? result / count : 0f); }
private void getCounts(string itemstring) { int count = 0; List <IMyCargoContainer> containers = new List <IMyCargoContainer>(); GridTerminalSystem.GetBlocksOfType(containers, (IMyCargoContainer block) => block.HasInventory); //Echo("Found " + containers.Count.ToString() + " containers"); for (int i = 0; i < containers.Count; i++) { IMyCargoContainer cont = containers[i]; List <MyInventoryItem> items = new List <MyInventoryItem>(); if (cont.HasInventory) { IMyInventory cont_inv = cont.GetInventory() as IMyInventory; cont_inv.GetItems(items, (MyInventoryItem item) => item.Type.ToString() == itemstring); //Echo("Found " + items.Count.ToString() + " items in " + cont.Name); for (int j = 0; j < items.Count; j++) { var item = items[j]; count += item.Amount.ToIntSafe(); } } } counts[itemstring] = count; }
public void Main(string argument, UpdateType updateSource) { var items = _CargoInterface.GetInventory().ItemCount; if (items > 0) { if (!_Flush) { _SorterIn.Enabled = false; _SorterOut.Enabled = true; _Flush = true; } } else if (_Flush) { _SorterOut.Enabled = false; _SorterIn.Enabled = true; _Flush = false; } _PanelTextSurface.WriteText(String.Format( "Items: {0}\nIn: {1}\nOut: {2}\nFlush: {3}", items, _SorterIn.Enabled, _SorterOut.Enabled, _Flush )); }
private void ViewCargoInventory(IMyCargoContainer cargo) { if (cargo == null) { Print("Контейнер не найден"); return; } Print($"Контейнер: {cargo.CustomName}"); IMyInventory inventory = cargo.GetInventory(); if (inventory != null) { Print($"items: {inventory.GetItems().Count}"); foreach (var item in inventory.GetItems()) { Print( $"{cargo.CustomName} \n\t\tN: {item.Content.SubtypeName}, \n\t\tI: {item.Content.SubtypeId}, \n\t\tT: {item.Content.TypeId}"); } } else { Print("Конейнер пуст"); } }
private bool empty(IMyTerminalBlock cube) { List <MyInventoryItem> li = new List <MyInventoryItem>(); IMyInventory src = cube.GetInventory(); src.GetItems(li); foreach (MyInventoryItem item in li) { //Echo("Trying to move "+item.Amount.ToIntSafe()+" of "+item.Type.SubtypeId+" from "+cube.CustomName); IMyCargoContainer box = getTargetToFill(); //Echo("Checking "+box.CustomName); IMyInventory tgt = box.GetInventory(); if (tryMove(src, tgt, item)) { Echo("Moved " + item.Amount.ToIntSafe() + " of " + item.Type.SubtypeId + " from " + cube.CustomName + " to " + box.CustomName); currentPreferredTarget = box; return(true); } else { currentPreferredTarget = null; } } return(false); }
public void Main(string containerName) { IMyCargoContainer cargo = FindBlock <IMyCargoContainer>(containerName); IMyTextPanel debug = FindBlock <IMyTextPanel>("debug"); if (cargo == null || debug == null) { debug.WritePublicText("Cargo or debug not found!", false); return; } IMyInventory cargoInventory = cargo.GetInventory(0); var assemblers = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyAssembler>(assemblers); for (int i = 0; i < assemblers.Count; i++) { if (!assemblers[i].HasInventory) { continue; } IMyInventory inventory = assemblers[i].GetInventory(1); List <IMyInventoryItem> items = inventory.GetItems(); debug.WritePublicText("Items Moved:" + items.Count + "\n", true); // Move items to cargo for (int j = 0; j < items.Count; j++) { inventory.TransferItemTo(cargoInventory, 0, null, stackIfPossible: true); } } }
private void UnloadCargo() { if (m_Connector.Status == MyShipConnectorStatus.Connected) { if (m_MainCargoContainer == null) { m_MainCargoContainer = GridTerminalSystem.GetBlockWithName(UnloadCargoName) as IMyCargoContainer; } if (m_MainCargoContainer != null) { var mainInventory = m_MainCargoContainer.GetInventory(0); foreach (var pair in m_AllBlocks) { var container = pair.Key as IMyCargoContainer; if (container != null) { var inventory = container.GetInventory(0); while (inventory.ItemCount != 0) { mainInventory.TransferItemFrom(inventory, 0, null, true); } } } } } }
public void setupContainerDict(IMyCargoContainer container) { bool found = false; List <IMyCargoContainer> tempList = new List <IMyCargoContainer>(); IMyInventory tempInv = container.GetInventory(); string volumeString = ""; if ((float)tempInv.CurrentVolume > 0.0f) { volumeString = " (" + (((float)tempInv.CurrentVolume / (float)tempInv.MaxVolume) * 100.0f).ToString("N1") + "%)"; } else { volumeString = " (0%)"; } foreach (string vString in CargoPrefix) { if (!(container_dict.ContainsKey(vString))) { container.CustomName = vString + " Cargo Container 01" + volumeString; tempList.Add(container); container_dict.Add(vString, tempList); found = true; break; } } if (!(found)) { Echo("Dict already contains the proper key.\n" + container.CustomName + " is lost"); } }
public void CheckProductionNeed(ref List <ControlObject> controlObjectList, ref FinalContainer finalContainer) { IMyGridTerminalSystem myGridTerminalSystem = null; IMyCargoContainer finalContainerUnico = null; foreach (ControlObject controlObject in controlObjectList) { MyItemType item = new MyItemType(controlObject.getComponentIDValue(), ""); for (int i = 0; i < finalContainer.getContainerName().Count(); i++) { finalContainerUnico = (IMyCargoContainer)myGridTerminalSystem.GetBlockWithName(finalContainer.getContainerName()[i]); if (finalContainerUnico != null) { MyInventoryItem myInventoryItem = (MyInventoryItem)finalContainerUnico.GetInventory().FindItem(item); if (myInventoryItem != null) { controlObject.setComponentsAmountProduced((int)myInventoryItem.Amount); controlObject.setComponentsAmountToProduce(controlObject.getComponetAmountKeepStorage() - controlObject.getComponentsAmountProduced()); } else { controlObject.setComponentsAmountProduced(controlObject.getComponetAmountKeepStorage()); controlObject.setComponentsAmountToProduce(controlObject.getComponetAmountKeepStorage()); } } } } }
private IMyCargoContainer getTargetToFill() { if (currentPreferredTarget != null && currentPreferredTarget.GetInventory().IsFull) { currentPreferredTarget = null; } return(currentPreferredTarget != null ? currentPreferredTarget : getRandom(containersToFill)); }
/// <summary> /// Sorts all containers /// </summary> /// <param name="_item">The item to be transfered</param> /// <param name="_itemIndex">Index of the item to be transfered</param> /// <param name="_containers">The list containing containers</param> /// <param name="_transferFrom">The container to transfer from</param> private void Sort_Item(IMyInventoryItem _item, int _itemIndex, List <IMyCargoContainer> _containers, IMyCargoContainer _transferFrom) { for (int i = 0; i < _containers.Count; i++) { if (_containers [i].CustomData == _item.Content.TypeId.ToString().Split('_') [1]) { _containers [i].GetInventory().TransferItemFrom(_transferFrom.GetInventory(), _itemIndex, stackIfPossible: true); } } }
void Main() { IMyInventory ContainerInventory = Container.GetInventory(0); ContainerInventory.GetItems(ContainerItems); LCD.WriteText("Cargo:\n", false); foreach (MyInventoryItem Item in ContainerItems) { LCD.WriteText("\n" + Item.Type.SubtypeId + ": " + Item.Amount, true); } }
public void OrganizeInventory(List <IMyCargoContainer> primaryStorage) { List <IMyInventory> inventories = GetInventories(); string componentStorageName = "Component Storage"; string oreIngotStorageName = "Ore and Ingot Storage"; string garbageStorageName = "Garbage Storage"; string gearStorageName = "Gear Storage"; IMyCargoContainer component = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(componentStorageName); IMyCargoContainer ironOre = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(oreIngotStorageName); IMyCargoContainer garbage = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(garbageStorageName); IMyCargoContainer gear = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(gearStorageName); if (component == null & ironOre == null) { primaryStorage[0].CustomName = componentStorageName; primaryStorage[1].CustomName = oreIngotStorageName; component = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(componentStorageName); ironOre = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(oreIngotStorageName); } else if (component == null) { primaryStorage[0].CustomName = componentStorageName; component = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(componentStorageName); } else if (ironOre == null) { primaryStorage[1].CustomName = oreIngotStorageName; ironOre = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName(oreIngotStorageName); } for (int y = 0; y < inventories.Count; y++) { if (inventories[y].GetItems().Count > 0) { List <IMyInventoryItem> items = inventories[y].GetItems(); for (int x = 0; x < items.Count; x++) { Echo(inventories[y].CurrentMass.ToString()); IMyInventoryItem item; item = items[x]; inventories[y].TransferItemTo(component.GetInventory(), x, null, true, item.Amount); } } } }
public void Main(string argument, UpdateType updateSource) { if ((updateSource & UpdateType.Terminal) == UpdateType.Terminal) { var invFrom = _cargo1.GetInventory(); var invTo = _cargo2.GetInventory(); var result = invFrom.TransferItemTo(invTo, 0, amount: 100); foreach (var item in invTo.GetItems()) { var defId = item.GetDefinitionId(); Echo(defId.SubtypeName); } } }
public static bool isConnectedToCargo(IMyCargoContainer container, IMyTerminalBlock block) { if (container.InventoryCount == 0) { return(false); } IMyInventory inventory = container.GetInventory(0); if (block.InventoryCount == 0) { return(true); } return(block.GetInventory(0).CanTransferItemTo(inventory, ICE_ITEM)); }
/// <summary> /// Automaticka kontrola rafinerii /// </summary> /// <returns>Cargo</returns> public Cargo EnableSorter() { // potrebne bloky Thrower = Instance.GetListByName <IMyShipConnector>("_Thrower", true).First(); Sorter = Instance.GetListByName <IMyCargoContainer>("_Sorter", true); Component = Instance.GetListByName <IMyCargoContainer>("_Component", true).First(); Ingot = Instance.GetListByName <IMyCargoContainer>("_Ingot", true).First(); Ore = Instance.GetListByName <IMyCargoContainer>("_Ore", true).First(); Ice = Instance.GetListByName <IMyCargoContainer>("_Ice", true).First(); // aktivace vyhazovace Thrower.ThrowOut = true; // vycucnuti zasob z konektoru, rafinerii a monteru foreach (KeyValuePair <string, IMyTerminalBlock> block in Instance.GetAll()) { // konektory if (block.Value is IMyShipConnector && !block.Key.Contains("_Thrower")) { TransferItems(block.Value.GetInventory(0)); } // vrtaky if (block.Value is IMyShipDrill) { TransferItems(block.Value.GetInventory(0)); } // rafinerie a pece if (block.Value is IMyRefinery) { TransferItems((block.Value as IMyRefinery).OutputInventory); //TransferItems((block.Value as IMyRefinery).InputInventory, true); } // monteri if (block.Value is IMyAssembler) { TransferItems((block.Value as IMyAssembler).OutputInventory); } } // serazovaci sklad foreach (IMyCargoContainer block in Sorter) { TransferItems(block.GetInventory(0)); } // presortovani kontejneru TransferItems(Component.GetInventory(0)); TransferItems(Ore.GetInventory(0)); TransferItems(Ingot.GetInventory(0)); // vraceni return(this); }
/// <summary> /// Fasst alle gleiche Items zu ein Stack zusammen /// </summary> /// <param name="cargo">IMyCargoContainer: Objekt des CargoContainer</param> public void ConcentrateCargo(IMyCargoContainer cargo) { IMyInventory c2 = cargo.GetInventory(); List <MyInventoryItem> cc = new List <MyInventoryItem>(); c2.GetItems(cc); for (int x = 0; x < cc.Count; x++) { for (int y = 0; y < cc.Count; y++) { if (getName(cc[x]) == getName(cc[y])) { c2.TransferItemTo(c2, x, y); } } } }
/// <summary> /// Метод возвращает содержимое контейнера (Тип содержимого: 10) /// </summary> /// <param name="Container">Контейр типа IMyCargoContainer</param> public List <string> GetInventoryData(IMyCargoContainer Container) { List <string> result = new List <string>(); List <MyInventoryItem> InventotyItems = new List <MyInventoryItem>(); InventotyItems.Clear(); IMyInventory Inventory = Container.GetInventory(0); Inventory.GetItems(InventotyItems); foreach (MyInventoryItem InventotyItem in InventotyItems) { result.Add(GetRusStr(InventotyItem.Type.SubtypeId) + ": " + InventotyItem.Amount.ToString()); } return(result); }
private void findMissing(IMyCargoContainer cargo) { for (int i = 0; i < cargo.InventoryCount; ++i) { IMyInventory inventory = cargo.GetInventory(i); _items.Clear(); //inventory.GetItems(_items);//, item => _amounts.ContainsKey(item.Type.SubtypeId)); inventory.GetItems(_items, item => _amounts.ContainsKey(item.Type.SubtypeId)); foreach (var item in _items) { /*if (item.Type.SubtypeId != "Stone") * { * _missing.Add(item.Type.SubtypeId + " " + item.Amount.RawValue / 1000000.0); * }*/ _amounts[item.Type.SubtypeId].amountRemaining -= item.Amount.RawValue; } } }
public void MoveStuff(IMyCargoContainer source, IMyCargoContainer dest, bool fullAmount) { IMyInventory src = source.GetInventory(); IMyInventory dst = dest.GetInventory(); var items = src.GetItems(); int itemCount = items.Count; for (int i = 0; i < itemCount; i++) { if (!fullAmount) { var itemstomove = items[i].Amount * (float)throttlePercentage; src.TransferItemTo(dst, i, null, true, itemstomove); } else { src.TransferItemTo(dst, i); } } }
private bool AddLoot(IMyCargoContainer container) { bool added = false; bool isLarge = container.CubeGrid.GridSizeEnum == MyCubeSize.Large; IMyInventory inventory = container.GetInventory(); try { if (MyUtils.GetRandomDouble(0, 1) <= (isLarge ? Tech2.chanceLarge : Tech2.chanceSmall)) { int amount = MyUtils.GetRandomInt((isLarge ? Tech2.minItemsLarge : Tech2.minItemsSmall), (isLarge ? Tech2.maxItemsLarge : Tech2.maxItemsSmall)); MyLog.Default.WriteLine("TieredTechBlocks: Added " + amount + "x Common Tech to " + container.CustomName); inventory.AddItems(amount, Tech2.builder); added = true; } if (MyUtils.GetRandomDouble(0, 1) <= (isLarge ? Tech4.chanceLarge : Tech4.chanceSmall)) { int amount = MyUtils.GetRandomInt((isLarge ? Tech4.minItemsLarge : Tech4.minItemsSmall), (isLarge ? Tech4.maxItemsLarge : Tech4.maxItemsSmall)); MyLog.Default.WriteLine("TieredTechBlocks: Added " + amount + "x Rare Tech to " + container.CustomName); inventory.AddItems(amount, Tech4.builder); added = true; } if (MyUtils.GetRandomDouble(0, 1) <= (isLarge ? Tech8.chanceLarge : Tech8.chanceSmall)) { int amount = MyUtils.GetRandomInt((isLarge ? Tech8.minItemsLarge : Tech8.minItemsSmall), (isLarge ? Tech8.maxItemsLarge : Tech8.maxItemsSmall)); MyLog.Default.WriteLine("TieredTechBlocks: Added " + amount + "x Exotic Tech to " + container.CustomName); inventory.AddItems(amount, Tech8.builder); added = true; } } catch (Exception e) { MyLog.Default.WriteLine("TieredTechBlocks: FAILED " + e); } return(added); }
public void Main(string argument, UpdateType updateSource) { StringBuilder message = new StringBuilder(); IMyTextPanel testLcd = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("TestDisplay"); testLcd.Font = "Monospace"; IMyCargoContainer cargoContainer = (IMyCargoContainer)GridTerminalSystem.GetBlockWithName("AssContainer"); List <IMyInventoryItem> test = cargoContainer.GetInventory().GetItems(); message.Clear(); foreach (IMyInventoryItem curItem in test) { message.Append(curItem.Content.SubtypeName + " " + curItem.Amount + "\n"); } List <IMySensorBlock> sensorList = new List <IMySensorBlock>(); List <MyDetectedEntityInfo> testList = new List <MyDetectedEntityInfo>(); GridTerminalSystem.GetBlocksOfType(sensorList); foreach (IMySensorBlock mySensor in sensorList) { mySensor.DetectedEntities(testList); message.Append("\n" + mySensor.CustomName + ": \n"); foreach (MyDetectedEntityInfo info in testList) { message.Append(info.Name + " | " + info.Relationship.+ "\n"); } } Echo(message + ""); testLcd.ShowPublicTextOnScreen(); testLcd.WritePublicText(message); }