InventoryListToLcd: add ores, formatting as a table

This commit is contained in:
2022-05-19 00:45:57 +03:00
parent 21e5c9fc37
commit 8ab8624d1a

View File

@@ -1,6 +1,6 @@
public Program()
{
Runtime.UpdateFrequency = UpdateFrequency.Update10;
Runtime.UpdateFrequency = UpdateFrequency.Update100;
}
public void Save()
@@ -28,24 +28,28 @@ public void Main(string argument, UpdateType updateSource)
{ "Platinum", 7 },
{ "Iron", 3 }
};
Dictionary<String,float> ores = new Dictionary<String,float>(ingots);
foreach (var container in containers)
{
foreach (var ingot in ingots.Keys.ToList())
{
ingots[ingot] += (float)container.GetInventory(0).GetItemAmount(new MyItemType("MyObjectBuilder_Ingot", ingot));
for (int i = 0; i < container.InventoryCount; i++)
{
ingots[ingot] += (float)container.GetInventory(i).GetItemAmount(new MyItemType("MyObjectBuilder_Ingot", ingot));
ores[ingot] += (float)container.GetInventory(i).GetItemAmount(new MyItemType("MyObjectBuilder_Ore", ingot));
}
}
}
// Dispaly
string output = "";
string output = " Ingots Ores\n-----------------------------------\n";
foreach (var ingot in ingots)
{
output += ingot.Key + " " + ingot.Value.ToString("n2") + "\n";
output += ingot.Key.PadRight(10) + " " + ingot.Value.ToString("n2").PadRight(15) + " " + ores[ingot.Key].ToString("n2") + "\n";
}
LCD.ContentType = ContentType.TEXT_AND_IMAGE;
LCD.WriteText(output);
}