Created
May 13, 2015 10:58
-
-
Save eikaas/03ae42563efe35e66852 to your computer and use it in GitHub Desktop.
Space Engineers - Refinery Status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void PrintList(IMyTextPanel panel, List<string> list) { | |
string str = ""; | |
for (int i = 0; i < list.Count; i++) { | |
str = str + list[i]; | |
} | |
panel.WritePublicText(str); | |
panel.ShowPublicTextOnScreen(); | |
} | |
void Main() { | |
bool all_ok = true; | |
List<string> error_messages = new List<string>(); | |
List<string> test_messages = new List<string>(); | |
List<string> status_messages = new List<string>(); | |
Color blue = new Color(0,0,255); | |
Color green = new Color(50, 200, 50); | |
Color yellow = new Color(200, 200, 50); | |
Color red = new Color(255,50,50); | |
IMyTimerBlock LoopTimer = (IMyTimerBlock) GridTerminalSystem.GetBlockWithName("MainTimer"); | |
IMyTextPanel errormon = (IMyTextPanel) GridTerminalSystem.GetBlockWithName("ErrorMonitor"); | |
IMyTextPanel statusmon = (IMyTextPanel) GridTerminalSystem.GetBlockWithName("StatusMonitor"); | |
IMyTextPanel testmon = (IMyTextPanel) GridTerminalSystem.GetBlockWithName("TestMonitor"); | |
List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>(); | |
// ErrorMonitor | |
if (errormon != null) { | |
errormon.SetValueFloat("FontSize", 1.8f); | |
errormon.SetValue("FontColor", red); | |
} | |
// StatusMonitor | |
if (statusmon != null) { | |
statusmon.SetValueFloat("FontSize", 1.8f); | |
statusmon.SetValue("FontColor", green); | |
} else { | |
error_messages.Add("is it really"); | |
error_messages.Add("statusmon is null"); | |
PrintList(errormon, error_messages); | |
} | |
// TestMonitor | |
if (testmon != null) { | |
testmon.SetValueFloat("FontSize", 1.8f); | |
testmon.SetValue("FontColor", green); | |
testmon.WritePublicTitle("Debug Panel", false); | |
} else { | |
error_messages.Add("statusmon is null"); | |
PrintList(errormon, error_messages); | |
} | |
PrintList(statusmon, status_messages); | |
PrintList(testmon, test_messages); | |
PrintList(errormon, error_messages); | |
GridTerminalSystem.GetBlocksOfType<IMyRefinery>(blocks); | |
List<ITerminalAction> actions = new List<ITerminalAction>(); | |
test_messages.Add("Refineries:\n"); | |
for (int i = 0; i < blocks.Count; i++) { | |
test_messages.Add(blocks[i].CustomName + ": "); | |
if (blocks[i].IsWorking) { | |
test_messages.Add("Working\n"); | |
} else { | |
test_messages.Add("STOPPED!\n"); | |
all_ok = false; | |
} | |
} | |
if (all_ok) { | |
statusmon.SetValue("FontColor", green); | |
testmon.SetValue("FontColor", green); | |
} else { | |
statusmon.SetValue("FontColor", red); | |
testmon.SetValue("FontColor", red); | |
} | |
PrintList(statusmon, test_messages); | |
PrintList(testmon, test_messages); | |
LoopTimer.GetActionWithName("Start").Apply(LoopTimer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment