Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions IngameScript/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ namespace IngameScript
partial class Program : MyGridProgram
{

Dictionary<string, string> componentItemBlueprintMap = new Dictionary<string, string>
{
{ "Construction", "ConstructionComponent"},
{ "Computer", "ComputerComponent"},
{ "Detector", "DetectorComponent"},
{ "Explosive", "ExplosiveComponent"},
{ "Girder", "GirderComponent"},
{ "GravityGenerator", "GravityGeneratorComponent"},
{ "Medical", "MedicalComponent"},
{ "Motor", "MotorComponent"},
{ "Reactor", "ReactorComponent"},
{ "RadioCommunication", "RadioCommunicationComponent"},
{ "Thrust", "ThrustComponent"},
};

IMyAssembler Assembler;
List<IMyCargoContainer> Containers;
List<IMyTextPanel> TextPanels;
Expand Down Expand Up @@ -51,6 +66,38 @@ partial class Program : MyGridProgram
//
// to learn more about ingame scripts.

private void debugInfoInventory()
{
var outText = "";
foreach (IMyEntity container in Containers)
{
var items = new List<MyInventoryItem>();
container.GetInventory().GetItems(items);
foreach (var item in items)
{
outText += item.ToString() + "\r\n";
}
}
foreach (IMyTextPanel textPanel in TextPanels)
{
textPanel.WriteText(outText);
}
}
private void debugInfoQueue()
{
var outText = "";
var items = new List<MyProductionItem>();
Assembler.GetQueue(items);
foreach (var item in items)
{
outText += item.BlueprintId.ToString() + "\r\n";
}
foreach (IMyTextPanel textPanel in TextPanels)
{
textPanel.WriteText(outText);
}
}

public Program()
{
// The constructor, called only once every session and
Expand Down Expand Up @@ -117,6 +164,9 @@ public void Main(string argument, UpdateType updateSource)
// The method itself is required, but the arguments above
// can be removed if not needed.

//debugInfoQueue();
//return;

List<MyProductionItem> assemblerQueue = new List<MyProductionItem>();
Assembler.GetQueue(assemblerQueue);

Expand Down Expand Up @@ -158,15 +208,20 @@ public void Main(string argument, UpdateType updateSource)

if (count < lowerBound)
{
AddToAssemblerQueueIfNotPresent(assemblerQueue, itemName, upperBound - count);
string blueprintName;
if (!componentItemBlueprintMap.TryGetValue(itemName, out blueprintName))
blueprintName = itemName;

AddToAssemblerQueueIfNotPresent(assemblerQueue, blueprintName, upperBound - count);
}

textPanelText += itemName + " " + count.ToString() + "\n";

}
catch (Exception e)
{

Echo("An error occurred during script execution.");
Echo($"Exception: {e}\n---");
}

}
Expand Down