Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Main()
- {
- // Name a LCD or Text Panel to "Vent Output: ..." Where ... is the name of the vent that
- // de-pressurizes your airlock. Keep in mind the space after : is needed!
- // Name your Interior and Exterior Door.
- string intDoor = "Airlock Interior";
- string extDoor = "Airlock Exterior";
- List<IMyTerminalBlock> screens = new List<IMyTerminalBlock>();
- List<IMyTerminalBlock> doors = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyDoor>(doors);
- GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(screens);
- for (int i = 0; i < screens.Count; i++)
- {
- IMyTextPanel screen = (IMyTextPanel)screens[i];
- var door1 = GridTerminalSystem.GetBlockWithName(intDoor) as IMyDoor;
- var door2 = GridTerminalSystem.GetBlockWithName (extDoor) as IMyDoor;
- if (screen.CustomName.IndexOf("Vent Output: ") == 0)
- {
- IMyAirVent vent = (IMyAirVent)GridTerminalSystem.GetBlockWithName(screen.CustomName.Substring(13));
- float airLevel;
- airLevel = vent.GetOxygenLevel();
- StringBuilder depressurize = new StringBuilder();
- vent.GetActionWithName("Depressurize").WriteValue(vent, depressurize);
- StringBuilder seal = new StringBuilder();
- door2.GetActionWithName("Open").WriteValue(door2, seal);
- screen.SetValue("FontSize", 3f);
- screen.ShowTextureOnScreen();
- screen.WritePublicText("\r\n Oxygen:\r\n "
- + String.Format("{0:P2}", airLevel)
- + "\r\n Depres: " + depressurize
- + "\r\n Seal: " + seal);
- screen.ShowPublicTextOnScreen();
- // Close Interior and Turn On Exterior
- if (depressurize.ToString() == "On" && airLevel > 0 && vent.IsPressurized() == true)
- {
- door1.GetActionWithName("Open_Off").Apply(door1);
- door2.GetActionWithName("OnOff_On").Apply(door2);
- }
- // Open Exterior and Turn Off Interior
- if (depressurize.ToString() == "On" && airLevel == 0 && vent.IsPressurized() == true)
- {
- door2.GetActionWithName("Open_On").Apply(door2);
- door1.GetActionWithName("OnOff_Off").Apply(door1);
- }
- // Close Exterior and Turn On Interior
- if (depressurize.ToString() == "Off" && airLevel == 0 && vent.IsPressurized() == false)
- {
- door2.GetActionWithName("Open_Off").Apply(door2);
- door1.GetActionWithName("OnOff_On").Apply(door1);
- }
- // Open Interior and Turn Off Exterior
- if (depressurize.ToString() == "Off" && airLevel > 0 && vent.IsPressurized() == true)
- {
- door1.GetActionWithName("Open_On").Apply(door1);
- door2.GetActionWithName("OnOff_Off").Apply(door2);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment