public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update100; } void Main(string arg) { var oreQuantities = new Dictionary() { {"Stone", 0}, {"Iron", 0}, {"Nickel", 0}, {"Cobalt", 0}, {"Magnesium", 0}, {"Silicon", 0}, {"Silver", 0}, {"Gold", 0}, {"Platinum", 0}, {"Uranium", 0}, {"Ice", 0}, }; var ingotQuantities = new Dictionary() { {"Stone", 0}, {"Cobalt", 0}, {"Gold", 0}, {"Iron", 0}, {"Magnesium", 0}, {"Nickel", 0}, {"Platinum", 0}, {"Silicon", 0}, {"Silver", 0}, {"Uranium", 0}, }; var inventoryBlocks = new List(); GridTerminalSystem.SearchBlocksOfName( "[BASE]", inventoryBlocks, block => (block is IMyCargoContainer || block is IMyProductionBlock) ); var columnLengths = new Dictionary(); foreach (var block in inventoryBlocks.Where(block => block.InventoryCount != 0)) { var items = new List(); if (block is IMyProductionBlock) { var inputItems = new List(); ((IMyProductionBlock) block).InputInventory.GetItems(inputItems); var outputItems = new List(); ((IMyProductionBlock) block).OutputInventory.GetItems(outputItems); items = inputItems.Concat(outputItems).ToList(); } else { block.GetInventory().GetItems(items); } foreach (var item in items) { Dictionary quantities; int column; var subtype = item.Type.TypeId.Split('_')[1]; if (subtype == "Ore") { quantities = oreQuantities; column = 0; } else if (subtype == "Ingot") { quantities = ingotQuantities; column = 2; } else { continue; } var itemName = item.Type.SubtypeId; quantities[itemName] = quantities.GetValueOrDefault(itemName) + (int) item.Amount; var columnMaxLength = columnLengths.GetValueOrDefault(column); if (itemName.Length > columnMaxLength) { columnLengths[column] = itemName.Length; } } } ingotQuantities["Gravel"] = ingotQuantities["Stone"]; ingotQuantities.Remove("Stone"); var ores = oreQuantities.OrderByDescending(pair => pair.Value).ToList(); var ingots = ingotQuantities.OrderByDescending(pair => pair.Value).ToList(); var text = new StringBuilder($"{"Ores",-17} | Ingots\n{new string('-', 18)}|{new string('-', 20)}\n"); for (int i = 0; i < ores.Count; i++) { var ore = ores[i].Key; var quantity = ores[i].Value; var oreCount = $"{((float) quantity / 1000):0.#}k"; text.Append($"{ore,-10} {oreCount,6} |"); if (i >= ingots.Count) { text.Append("\n"); continue; } var ingot = ingots[i].Key; quantity = ingots[i].Value; var ingotCount = $"{((float) quantity / 1000):0.#}k"; text.Append($" {ingot,-10} {ingotCount,6}\n"); } if (ingots.Count > ores.Count) { for (int i = ores.Count; i < ingots.Count; i++) { var ingot = ingots[i].Key; var quantity = ingots[i].Value; var ingotCount = $"{((float) quantity / 1000):0.#}k"; text.Append($"{new string(' ', 19)} {ingot,-10} {ingotCount,6}\n"); } } ((IMyTextPanel) GridTerminalSystem.GetBlockWithName("LCD Ore Quantities")).WriteText(text.ToString()); }