Created
December 19, 2018 13:17
-
-
Save untodesu/cc48d46cecbb428ba98020adb54a1960 to your computer and use it in GitHub Desktop.
Space Engineers BAGBA1 Single ring GATE Controller
This file contains hidden or 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
| /* | |
| * The BAGBA1 Ring Controller Script | |
| * Made by UND85D/undbsd | |
| * Fully(I think) auto | |
| * | |
| * Part of BAGBA1 Controller System | |
| * | |
| * btw BAGBA = BBA | |
| */ | |
| uint ringNumber; //Ring number, starts from zero | |
| string timerName; | |
| string aggName; | |
| string litName; | |
| List<IMyGravityGenerator> gravityGenerators; | |
| List<IMyInteriorLight> interiorLights; | |
| bool init = false; | |
| public Program() | |
| { | |
| ringNumber = 0; //Number of ring | |
| timerName = String.Format("BBA.Ring[{0}].DisableTimer", ringNumber); | |
| aggName = String.Format("BBA.Ring[{0}].AGG", ringNumber); | |
| litName = String.Format("BBA.Ring[{0}].Light", ringNumber); | |
| gravityGenerators = new List<IMyGravityGenerator>(); | |
| interiorLights = new List<IMyInteriorLight>(); | |
| } | |
| public void Main(string arg) | |
| { | |
| switch(arg) { | |
| case "_ring_RENAME": { //ONLY for standalone Rings, renames all gravity generators to selected name | |
| List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>(); | |
| GridTerminalSystem.GetBlocksOfType<IMyGravityGenerator>(blocks); | |
| List<IMyGravityGenerator> ggaAll = blocks.ConvertAll<IMyGravityGenerator>(x => (IMyGravityGenerator)x); | |
| foreach(IMyGravityGenerator agg in ggaAll) { | |
| agg.CustomName = aggName; | |
| agg.ShowInTerminal = false; | |
| agg.ShowInToolbarConfig = false; | |
| } | |
| Echo("Generators: DONE"); | |
| blocks = new List<IMyTerminalBlock>(); | |
| GridTerminalSystem.GetBlocksOfType<IMyInteriorLight>(blocks); | |
| List<IMyInteriorLight> litAll = blocks.ConvertAll<IMyInteriorLight>(x => (IMyInteriorLight)x); | |
| foreach(IMyInteriorLight il in litAll) { | |
| il.CustomName = litName; | |
| il.ShowInTerminal = false; | |
| il.ShowInToolbarConfig = false; | |
| } | |
| Echo("Lights: DONE"); | |
| break; | |
| }; | |
| case "bba_ringInit": { //Init for ALL rings, used for detecting ring's aggs | |
| List<IMyTerminalBlock> blocks = new List<IMyTerminalBlock>(); | |
| GridTerminalSystem.GetBlocksOfType<IMyGravityGenerator>(blocks); | |
| List<IMyGravityGenerator> ggaAll = blocks.ConvertAll<IMyGravityGenerator>(x => (IMyGravityGenerator)x); | |
| foreach (IMyGravityGenerator agg in ggaAll) { | |
| if (agg.CustomName == aggName && !gravityGenerators.Contains(agg)) { | |
| gravityGenerators.Add(agg); | |
| } | |
| } | |
| blocks = new List<IMyTerminalBlock>(); | |
| GridTerminalSystem.GetBlocksOfType<IMyInteriorLight>(blocks); | |
| List<IMyInteriorLight> litAll = blocks.ConvertAll<IMyInteriorLight>(x => (IMyInteriorLight)x); | |
| foreach (IMyInteriorLight il in litAll) { | |
| if (il.CustomName == litName && !interiorLights.Contains(il)) { | |
| interiorLights.Add(il); | |
| } | |
| } | |
| init = true; | |
| break; | |
| }; | |
| case "bba_getInfo": { //InfoGET for Main BAGBA Controller | |
| Me.CustomData = String.Format("BAGBA ring {0}", ringNumber); | |
| break; | |
| }; | |
| case "bba_ringStart": { | |
| if(init) { | |
| foreach(IMyGravityGenerator agg in gravityGenerators) { | |
| agg.Enabled = true; | |
| } | |
| foreach (IMyInteriorLight il in interiorLights) { | |
| il.Enabled = true; | |
| } | |
| } | |
| else { | |
| Echo(String.Format("BAGBA.Start(): Ring #{0} is not ready to start!", ringNumber)); | |
| } | |
| break; | |
| }; | |
| case "bba_ringStop": { | |
| if (init) { | |
| foreach (IMyGravityGenerator agg in gravityGenerators) { | |
| agg.Enabled = false; | |
| } | |
| foreach (IMyInteriorLight il in interiorLights) { | |
| il.Enabled = false; | |
| } | |
| } | |
| else { | |
| Echo(String.Format("BAGBA.Stop(): Ring #{0} is not ready to start!", ringNumber)); | |
| } | |
| break; | |
| }; | |
| } | |
| } | |
| public void Save() | |
| { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment