ich habe mir das Scripts Automatische Produktion geholt was mir immer einen Mindestbestand an teilen Herstellen soll bei den Standard sachen von Space Engineers geht das aber bei mods geht nur ein item was er den auch nach Produziert aber bei den andren nicht wieso ?
Kennt sonst ein besser n
steamcommunity.com/sharedfiles/filedetails/?id=954235017
/* #############################################
Stellt automatisch einen Grundstock an Komponenten her der hier hinterlegt wird.
Script by n30nl1ght
#############################################*/
/*
BulletproofGlass
Computer
Construction
Detector
Display
Explosives
Girder
GravityGenerator
InteriorPlate
LargeTube
Medical
MetalGrid
Motor
PowerCell
RadioCommunication
Reactor
SmallTube
SolarCell
SteelPlate
Thrust
*/
public class Settings{
public static string storageTag = "Komponenten";
public static string assemblerTag = "Automatic";
}
public void Main(string argument) {
List<IMyTerminalBlock> assemblers = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType<IMyAssembler>(assemblers);
List<IMyTerminalBlock> workAssembler = new List<IMyTerminalBlock>();
GridTerminalSystem.SearchBlocksOfName("(" + Settings.assemblerTag + ")", workAssembler);
Dictionary<String, VRage.MyFixedPoint> materialCurrent = new Dictionary<String, VRage.MyFixedPoint>();
Dictionary<String, VRage.MyFixedPoint> materialQuota = new Dictionary<String, VRage.MyFixedPoint>();
List<IMyTerminalBlock> containers = new List<IMyTerminalBlock>();
GridTerminalSystem.SearchBlocksOfName("(" + Settings.storageTag + ")", containers);
// Prüfe ob nur ein Assembler für die automatische produktion markiert wurde
// ANsonsten scriptr abbrechen.
if(workAssembler.Count > 1){
Echo("Es kann nur eine Montageanlage zur automatischen Produktion verwendet werden");
return;
}
// Lesen der einstellungen des Users
string inputs = workAssembler[0].CustomData;
string[] quotaComponent = inputs.Split(new Char [] {'\n'});
foreach( string s in quotaComponent){
string[] quota = s.Split(new Char [] {'='});
materialQuota.Add(CreateBlueprintName(quota[0]), (VRage.MyFixedPoint)Convert.ToInt32(quota[1]));
}
// Prüfe die Warteschlange des assemblers und berücksichtige dies Anzahl
for(int i = 0; i < assemblers.Count; i++)
{
IMyAssembler assembler = (IMyAssembler)assemblers;
var assemblerInventory = assembler.GetInventory(1);
var assemblerItems = assemblerInventory.GetItems();
List<MyProductionItem> prodList = new List<MyProductionItem>();
for(int i2 = 0; i2 < assemblerItems.Count; i2++) {
string assemblerItemName = assemblerItems[i2].Content.SubtypeId.ToString();
assemblerItemName = CreateBlueprintName(assemblerItemName);
if(materialCurrent.ContainsKey(assemblerItemName)){
materialCurrent[assemblerItemName] += assemblerItems[i2].Amount;
} else {
materialCurrent.Add(assemblerItemName, assemblerItems[i2].Amount);
}
}
if(assembler.IsQueueEmpty){
Echo(assembler.CustomName+ " : Queue empty");
} else {
Echo(assembler.CustomName+ " : Pending");
assembler.GetQueue(prodList);
for(int k = 0; k < prodList.Count; k++){
string componentName = prodList[k].BlueprintId.SubtypeName.ToString();
componentName = CreateBlueprintName(componentName);
if(materialCurrent.ContainsKey(componentName)){
materialCurrent[componentName] += prodList[k].Amount;
} else {
materialCurrent.Add(componentName, prodList[k].Amount);
}
}
}
}
// Prüfe den Stock in den Containern die als solche markiert wurden
for(int i = 0; i < containers.Count; i++){
var containerInventory = containers[i].GetInventory(0);
var containerItems = containerInventory.GetItems();
for(int i2 = 0; i2 < containerItems.Count; i2++) {
string containerItemName = containerItems[i2].Content.SubtypeId.ToString();
containerItemName = CreateBlueprintName(containerItemName);
if(materialCurrent.ContainsKey(containerItemName)){
materialCurrent[containerItemName] += containerItems[i2].Amount;
} else {
materialCurrent.Add(containerItemName, containerItems[i2].Amount);
}
}
}
foreach(KeyValuePair<string, VRage.MyFixedPoint> s in materialQuota)
{
VRage.MyFixedPoint componentsToBuild = (VRage.MyFixedPoint)0;
VRage.MyFixedPoint componentCurrent = 0;
VRage.MyFixedPoint componentQuota = (VRage.MyFixedPoint)s.Value;
MyDefinitionId objectIdToAdd = new MyDefinitionId();
IMyAssembler targetAssembler = (IMyAssembler)workAssembler[0];
if(materialCurrent.ContainsKey(s.Key)){
componentCurrent = materialCurrent[s.Key];
componentsToBuild = componentQuota - componentCurrent;
} else {
componentsToBuild = componentQuota;
}
if(componentsToBuild > 0){
objectIdToAdd = MyDefinitionId.Parse("MyObjectBuilder_BlueprintDefinition/" + s.Key);
targetAssembler.AddQueueItem(objectIdToAdd, componentsToBuild);
Echo(s.Key + " : " + componentCurrent.ToString() + " / " + componentQuota.ToString() + " = " + componentsToBuild.ToString());
}
}
}
public string CreateBlueprintName (string name){
switch(name){
case "RadioCommunication" : name += "Component"; break;
case "Computer" : name += "Component"; break;
case "Reactor" : name += "Component"; break;
case "Detector" : name += "Component"; break;
case "Construction" : name += "Component"; break;
case "Thrust" : name += "Component"; break;
case "Motor" : name += "Component"; break;
case "Explosives" : name += "Component"; break;
case "Girder" : name += "Component"; break;
case "GravityGenerator" : name += "Component"; break;
case "Medical" : name += "Component"; break;
case "NATO_25x184mm" : name += "Magazine"; break;
case "NATO_5p56x45mm" : name += "Magazine"; break;
}
return name;
}
Kennt sonst ein besser n
steamcommunity.com/sharedfiles/filedetails/?id=954235017
/* #############################################
Stellt automatisch einen Grundstock an Komponenten her der hier hinterlegt wird.
Script by n30nl1ght
#############################################*/
/*
BulletproofGlass
Computer
Construction
Detector
Display
Explosives
Girder
GravityGenerator
InteriorPlate
LargeTube
Medical
MetalGrid
Motor
PowerCell
RadioCommunication
Reactor
SmallTube
SolarCell
SteelPlate
Thrust
*/
public class Settings{
public static string storageTag = "Komponenten";
public static string assemblerTag = "Automatic";
}
public void Main(string argument) {
List<IMyTerminalBlock> assemblers = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType<IMyAssembler>(assemblers);
List<IMyTerminalBlock> workAssembler = new List<IMyTerminalBlock>();
GridTerminalSystem.SearchBlocksOfName("(" + Settings.assemblerTag + ")", workAssembler);
Dictionary<String, VRage.MyFixedPoint> materialCurrent = new Dictionary<String, VRage.MyFixedPoint>();
Dictionary<String, VRage.MyFixedPoint> materialQuota = new Dictionary<String, VRage.MyFixedPoint>();
List<IMyTerminalBlock> containers = new List<IMyTerminalBlock>();
GridTerminalSystem.SearchBlocksOfName("(" + Settings.storageTag + ")", containers);
// Prüfe ob nur ein Assembler für die automatische produktion markiert wurde
// ANsonsten scriptr abbrechen.
if(workAssembler.Count > 1){
Echo("Es kann nur eine Montageanlage zur automatischen Produktion verwendet werden");
return;
}
// Lesen der einstellungen des Users
string inputs = workAssembler[0].CustomData;
string[] quotaComponent = inputs.Split(new Char [] {'\n'});
foreach( string s in quotaComponent){
string[] quota = s.Split(new Char [] {'='});
materialQuota.Add(CreateBlueprintName(quota[0]), (VRage.MyFixedPoint)Convert.ToInt32(quota[1]));
}
// Prüfe die Warteschlange des assemblers und berücksichtige dies Anzahl
for(int i = 0; i < assemblers.Count; i++)
{
IMyAssembler assembler = (IMyAssembler)assemblers;
var assemblerInventory = assembler.GetInventory(1);
var assemblerItems = assemblerInventory.GetItems();
List<MyProductionItem> prodList = new List<MyProductionItem>();
for(int i2 = 0; i2 < assemblerItems.Count; i2++) {
string assemblerItemName = assemblerItems[i2].Content.SubtypeId.ToString();
assemblerItemName = CreateBlueprintName(assemblerItemName);
if(materialCurrent.ContainsKey(assemblerItemName)){
materialCurrent[assemblerItemName] += assemblerItems[i2].Amount;
} else {
materialCurrent.Add(assemblerItemName, assemblerItems[i2].Amount);
}
}
if(assembler.IsQueueEmpty){
Echo(assembler.CustomName+ " : Queue empty");
} else {
Echo(assembler.CustomName+ " : Pending");
assembler.GetQueue(prodList);
for(int k = 0; k < prodList.Count; k++){
string componentName = prodList[k].BlueprintId.SubtypeName.ToString();
componentName = CreateBlueprintName(componentName);
if(materialCurrent.ContainsKey(componentName)){
materialCurrent[componentName] += prodList[k].Amount;
} else {
materialCurrent.Add(componentName, prodList[k].Amount);
}
}
}
}
// Prüfe den Stock in den Containern die als solche markiert wurden
for(int i = 0; i < containers.Count; i++){
var containerInventory = containers[i].GetInventory(0);
var containerItems = containerInventory.GetItems();
for(int i2 = 0; i2 < containerItems.Count; i2++) {
string containerItemName = containerItems[i2].Content.SubtypeId.ToString();
containerItemName = CreateBlueprintName(containerItemName);
if(materialCurrent.ContainsKey(containerItemName)){
materialCurrent[containerItemName] += containerItems[i2].Amount;
} else {
materialCurrent.Add(containerItemName, containerItems[i2].Amount);
}
}
}
foreach(KeyValuePair<string, VRage.MyFixedPoint> s in materialQuota)
{
VRage.MyFixedPoint componentsToBuild = (VRage.MyFixedPoint)0;
VRage.MyFixedPoint componentCurrent = 0;
VRage.MyFixedPoint componentQuota = (VRage.MyFixedPoint)s.Value;
MyDefinitionId objectIdToAdd = new MyDefinitionId();
IMyAssembler targetAssembler = (IMyAssembler)workAssembler[0];
if(materialCurrent.ContainsKey(s.Key)){
componentCurrent = materialCurrent[s.Key];
componentsToBuild = componentQuota - componentCurrent;
} else {
componentsToBuild = componentQuota;
}
if(componentsToBuild > 0){
objectIdToAdd = MyDefinitionId.Parse("MyObjectBuilder_BlueprintDefinition/" + s.Key);
targetAssembler.AddQueueItem(objectIdToAdd, componentsToBuild);
Echo(s.Key + " : " + componentCurrent.ToString() + " / " + componentQuota.ToString() + " = " + componentsToBuild.ToString());
}
}
}
public string CreateBlueprintName (string name){
switch(name){
case "RadioCommunication" : name += "Component"; break;
case "Computer" : name += "Component"; break;
case "Reactor" : name += "Component"; break;
case "Detector" : name += "Component"; break;
case "Construction" : name += "Component"; break;
case "Thrust" : name += "Component"; break;
case "Motor" : name += "Component"; break;
case "Explosives" : name += "Component"; break;
case "Girder" : name += "Component"; break;
case "GravityGenerator" : name += "Component"; break;
case "Medical" : name += "Component"; break;
case "NATO_25x184mm" : name += "Magazine"; break;
case "NATO_5p56x45mm" : name += "Magazine"; break;
}
return name;
}