Closed Just0Focus closed 2 years ago
` #region code public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; }
void Main()
{
List<IMyTerminalBlock> nanites = new List<IMyTerminalBlock>();
List<IMyTextPanel> lcd = new List<IMyTextPanel>();
List<int> nfStats = new List<int>(5) { 0,0,0,0,0};
List<String> nfStatus = new List<string>();
int nfActives = 0;
int nfPower = 0;
String nfMissingComp = "";
GridTerminalSystem.GetBlocksOfType<IMyOxygenFarm>(
nanites,
(block) => block.CustomName.Contains("Factory")
);
int nFactorys = 0;
foreach (IMyTerminalBlock nf in nanites)
{
string[] NFStat = { "" };
nfStatus.Add("");
if (nf != null) NFStat = nf.CustomInfo.Split('\n');
//Echo("Processing: " + nf.CustomName);
for (int i = 0; i < NFStat.Length; i++)
{
if (NFStat[i].IndexOf("Status") >= 0) nfStatus[nFactorys] = nf.CustomName.Replace("Nanite Control Factory","NCF") + ": " + NFStat[i].Split(':')[1];
if (NFStat[i].IndexOf("Active Nanites") >= 0) { nfActives += int.Parse(NFStat[i].Split(':')[1]); }
if (NFStat[i].IndexOf("Current Power") >= 0) {
String sVal = NFStat[i].Split(':')[1];
int nLength = sVal.Length;
int np = int.Parse(sVal.Substring(0, nLength - 3));
//Echo(sVal.Substring(nLength-3,2));
switch (sVal.Substring(nLength - 3, 2))
{
case "kW":
break;
case "MW":
np = np * 1000;break;
case "GW":
np = np * 1000000;break;
default:
break;
}
//Echo("Power : " + sVal + "/" + np);
nfPower += np;
}
if (NFStat[i].IndexOf("Possible Construction") >= 0) { nfStats[0] += int.Parse(NFStat[i].Split(':')[1]); }
if (NFStat[i].IndexOf("Possible Deconstruction") >= 0) nfStats[1] += int.Parse(NFStat[i].Split(':')[1]);
if (NFStat[i].IndexOf("Possible Floating") >= 0) nfStats[2] += int.Parse(NFStat[i].Split(':')[1]);
if (NFStat[i].IndexOf("Possible Projection") >= 0) nfStats[3] += int.Parse(NFStat[i].Split(':')[1]);
if (NFStat[i].IndexOf("Possible Mining") >= 0) nfStats[4] += int.Parse(NFStat[i].Split(':')[1]);
if (NFStat[i].IndexOf("Missing components") >= 0)
{
for (int j = i + 1; j < NFStat.Length - 1; j++)
{
nfMissingComp+= " -"+NFStat[j] + "\n";
}
}
}
nFactorys++;
}
string sDebug = "";
if (nanites.Count != 0)
{
sDebug+="-= ";
if (nanites.Count > 1) sDebug += nanites.Count + " ";
sDebug += "Nanite Factory";
if (nanites.Count > 1) sDebug += "s";
sDebug += " =- \n";
sDebug += "--<Tasks>--\n";
if( nfStats[0] > 0 ) sDebug += "Construction : " + (nfStats[0] / nanites.Count + "\n");
if (nfStats[1] > 0) sDebug += "Deconstruction: " + (nfStats[1] / nanites.Count + "\n");
if (nfStats[2] > 0) sDebug += "Floating : " + (nfStats[2] / nanites.Count + "\n");
if (nfStats[3] > 0) sDebug += "Projection : " + (nfStats[3] / nanites.Count + "\n");
if (nfStats[4] > 0) sDebug += "Mining : " + (nfStats[4] / nanites.Count + "\n");
sDebug += "--<Status>--\n";
if(nfPower>1000000) sDebug += "Power : " + nfPower/1000000 +" GW\n";
else if (nfPower > 1000) sDebug += "Power : " + nfPower / 1000 + " MW\n";
else sDebug += "Power : " + nfPower + " kW\n";
sDebug += "Actives: " + nfActives +"\n";
sDebug += "Status :\n";
for(int i = 0; i < nanites.Count; i++)
{
if (nfStatus[i] != "" && !nfStatus[i].Contains("Enabled")) sDebug += " -" + nfStatus[i] + "\n";
}
if(nfMissingComp!="") sDebug += "Missing :\n" + nfMissingComp;
}
else
{
sDebug = "Missing Factory";
Echo("Missing Factory");
}
GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(
lcd,
(block) => block.CustomName.Contains("nf")
);
if (lcd.Count == 0)
{
Echo(sDebug);
}
else
{
foreach(IMyTextPanel ld in lcd)
{
Echo("OnScreen : " + ld.CustomName);
ld.WritePublicText(sDebug, false);
}
}
}
#endregion
`
This Comes up with Missing
How do I display Nanite Control Facility Blocks "Detailed text" onto a Display?