Space Engineers

Space Engineers

Not enough ratings
Script checks turrets v1.1
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
845.000 B
29 Jan, 2015 @ 12:30am
29 Jan, 2015 @ 12:56am
2 Change Notes ( view )

Subscribe to download
Script checks turrets v1.1

Description
script checks the integrity and number of turrets.
This simple and easy to configure script checks the number of turrets and their performance.


// Change these string

const int TURRETS_COUNT = 3;
const bool TURRETS_ALARM_ON = true; // true/false true -on all TURRETS if alarm
const string ACTION_TIMERS_NAME = "Timer Block action";
const string TEXT_BLOCKS_NAME = "error log";


// Roon_Booh by for MagariSimoku 29/01/2015
List<IMyTerminalBlock> baseTurrets = new List<IMyTerminalBlock>();
List<IMyTerminalBlock> actionTimers = new List<IMyTerminalBlock>();
List<IMyTerminalBlock> alarmLogBlocks = new List<IMyTerminalBlock>();


void Main() {

baseTurrets.Clear();
actionTimers.Clear();

GridTerminalSystem.GetBlocksOfType<IMyLargeTurretBase>(baseTurrets);
GridTerminalSystem.SearchBlocksOfName(ACTION_TIMERS_NAME, actionTimers);
GridTerminalSystem.SearchBlocksOfName(TEXT_BLOCKS_NAME, alarmLogBlocks);

bool alarmAction = false;
string text = TEXT_BLOCKS_NAME + "\n";

for (int a = 0; a < baseTurrets.Count; a++) {
if (!baseTurrets[a].IsFunctional) {
alarmAction = true;
text += baseTurrets[a].CustomName + " broken\n";
}
else if (baseTurrets[a].IsBeingHacked) {
alarmAction = true;
text += baseTurrets[a].CustomName + " cracked\n";
}
}

if (baseTurrets.Count < TURRETS_COUNT) {
alarmAction = true;
text += (baseTurrets.Count + "/" + TURRETS_COUNT + " Destroy Blocks\n");
}

for (int ia = 0; ia < alarmLogBlocks.Count; ia++) {
alarmLogBlocks[ia].SetCustomName(text);
}

if (alarmAction == true) {
for (int j = 0; j < actionTimers.Count; j++) {
actionTimers[j].GetActionWithName("OnOff_On").Apply(actionTimers[j]);
actionTimers[j].GetActionWithName("Stop").Apply(actionTimers[j]);
actionTimers[j].GetActionWithName("TriggerNow").Apply(actionTimers[j]);
}

if (TURRETS_ALARM_ON) {
for (int x1 = 0; x1 < baseTurrets.Count; x1++) {
baseTurrets[x1].GetActionWithName("OnOff_On").Apply(baseTurrets[x1]);
}
}
}
//group.Blocks.IsFunctional
}
2 Comments
Roon_Boh  [author] 7 Mar, 2015 @ 11:11am 
I can make the necessary changes, but I do not know what method to write in text or LSD panel. The light can be turned on, alarming clock, so the script when obnoruzhenii fault turret or its absence activate an alarm timer, and if the mood in your script that includes all the turret.
Weyrman Albie 14 Feb, 2015 @ 5:34am 
Can condition of OK or normal error output be written to a text panel and a light triggered if not ok?