private void PistonControl(string switchName, string displayNum, string pistonName, string action) { IMyButtonPanel panel = (IMyButtonPanel)GridTerminalSystem.GetBlockWithName(switchName); IMyTextSurface surface = ((IMyTextSurfaceProvider)panel).GetSurface(Int32.Parse(displayNum)); IMyPistonBase piston = (IMyPistonBase)GridTerminalSystem.GetBlockWithName(pistonName); if (action == "On/Off") { bool pistonEnabled = piston.Enabled; if (pistonEnabled) { surface.BackgroundColor = Color.Red; } else { surface.BackgroundColor = Color.Green; } piston.Enabled = !pistonEnabled; } if (action == "Reverse") { piston.Reverse(); if (piston.Velocity < 0) { surface.BackgroundColor = Color.Red; } else { surface.BackgroundColor = Color.Green; } } }
public void StartAssigning() { List <IMyTextPanel> textBlocks = new List <IMyTextPanel>(); GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(textBlocks); var primaryLcd = textBlocks.Find(textBlock => textBlock.CustomName.StartsWith("[PRIMARY]")); if (primaryLcd == null) { Echo("Could not find primary LCD"); return; } lcd = new ListLCDInterface( primaryLcd, "Assign Outputs", textBlocks.Select(textBlock => textBlock.CustomName).ToList() ); List <IMyButtonPanel> buttonBlocks = new List <IMyButtonPanel>(); GridTerminalSystem.GetBlocksOfType <IMyButtonPanel>(buttonBlocks); button = buttonBlocks.Find(buttonBlock => buttonBlock.CustomName.StartsWith("[PRIMARY_CONTROL]")); if (button == null) { Echo("Could not find primary Button control"); return; } }
bool FuncTest(IMyButtonPanel block) { //Button Panel //Interface name: IMyButtonPanel //Fields: bool AnyoneCanUse = block.AnyoneCanUse; return(true); }
public void BindButtonPanel(IMyButtonPanel btnpnl) { if (buttons != null) { buttons.ButtonPressed -= ButtonPanelHandler; } buttons = btnpnl; buttons.ButtonPressed += ButtonPanelHandler; }
public void BindButtonPanel(IMyButtonPanel btnpnl) { //if (Buttons != null) //{ // Buttons.ButtonPressed -= ButtonPanelHandler; //} Buttons = btnpnl; //Buttons.ButtonPressed += ButtonPanelHandler; var blockDef = (MyButtonPanelDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(Buttons.BlockDefinition); Buttons.SetEmissiveParts("Emissive1", blockDef.ButtonColors[1 % blockDef.ButtonColors.Length], 1); Buttons.SetEmissiveParts("Emissive2", blockDef.ButtonColors[2 % blockDef.ButtonColors.Length], 1); Buttons.SetEmissiveParts("Emissive3", blockDef.ButtonColors[3 % blockDef.ButtonColors.Length], 1); Buttons.SetEmissiveParts("Emissive4", blockDef.ButtonColors[4 % blockDef.ButtonColors.Length], 1); }
public bool TryFindButtonPanel(Vector3I Position, IMyCubeGrid Grid, out IMyButtonPanel Match) { IMySlimBlock SlimBlock = Grid.GetCubeBlock(Position); if (SlimBlock != null && SlimBlock.FatBlock != null && SlimBlock.FatBlock is IMyTerminalBlock && SlimBlock.FatBlock is IMyButtonPanel) { Match = SlimBlock.FatBlock as IMyButtonPanel; return(true); } else { Match = null; return(false); } }
IMyTextSurface[] ButtonPanelTextAssignments(string lcdPanelName) { IMyButtonPanel bp = GridTerminalSystem.GetBlockWithName("Button Panel One") as IMyButtonPanel; int numButtonScreens = ((IMyTextSurfaceProvider)bp).SurfaceCount; IMyTextSurface[] screens = new IMyTextSurface[numButtonScreens]; for (int i = 0; i < screens.Length; i++) { screens[i] = ((IMyTextSurfaceProvider)bp).GetSurface(i); screens[i].BackgroundColor = new Color(0, 80, 255); screens[i].FontColor = new Color(255, 255, 255); screens[i].Alignment = TextAlignment.CENTER; screens[i].FontSize = 2.5f; } return(screens); }
private void ToggleDisplaySwitch(string switchName, string displayNum, string blockName) { IMyButtonPanel panel = (IMyButtonPanel)GridTerminalSystem.GetBlockWithName(switchName); IMyTextSurface surface = ((IMyTextSurfaceProvider)panel).GetSurface(Int32.Parse(displayNum)); IMyFunctionalBlock block = (IMyFunctionalBlock)GridTerminalSystem.GetBlockWithName(blockName); bool isPowered = block.Enabled; if (isPowered) { surface.BackgroundColor = Color.Red; } else { surface.BackgroundColor = Color.Green; } block.Enabled = !isPowered; }
private List <IMyButtonPanel> GetButtonPanels(IMyGridTerminalSystem gts, IMyCubeGrid desiredGrid) { List <IMyButtonPanel> buttonList = new List <IMyButtonPanel>(); List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock> { }; gts.GetBlocksOfType <IMyButtonPanel>(blocks); for (int i = 0; i < blocks.Count; i++) { IMyButtonPanel currentButton = (IMyButtonPanel)blocks[i]; if (currentButton.CubeGrid != desiredGrid) { continue; // Ignore panels not on this grid } buttonList.Add(currentButton); } return(buttonList); }
public void progressPanel(IMyTextPanel Panel) { IMyButtonPanel ButtonPanel = getButtonPanel(Panel); if (ButtonPanel != null) { StringBuilder slug = new StringBuilder(); for (int i = 0; i < 4; i++) { if (ButtonPanel.IsButtonAssigned(i) && ButtonPanel.HasCustomButtonName(i)) { slug.AppendLine(string.Format(@"[{0}]: {1}", i + 1, ButtonPanel.GetButtonName(i))); } else { slug.AppendLine(string.Format(@"[{0}]: ...", i + 1)); } } Panel.WritePublicText(slug.ToString()); Panel.WritePublicTitle(ButtonPanel.CustomName); Panel.SetValueFloat("FontSize", 0.65f); Panel.ShowPublicTextOnScreen(); } }
public IMyButtonPanel getButtonPanel(IMyTextPanel Panel) { if (Cache.ContainsKey(Panel)) { IMyTerminalBlock buffer = GridTerminalSystem.GetBlockWithId(Cache[Panel].EntityId); if (buffer != null && buffer is IMyButtonPanel) { return(buffer as IMyButtonPanel); } else { Cache.Remove(Panel); } } IMyButtonPanel ButtonPanel = findButtonPanelFromLCD(Panel); if (ButtonPanel != null && ButtonPanel is IMyButtonPanel) { Cache.Add(Panel, ButtonPanel); return(ButtonPanel); } return(null); }
public void Main(string argument, UpdateType updateSource) { Runtime.UpdateFrequency = UpdateFrequency.Update10; IMyTextPanel codeScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("KodePanel"); IMyTextPanel acceptScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("AcceptScreen"); IMyDoor myDoor = (IMyDoor)GridTerminalSystem.GetBlockWithName("CommandDoor"); IMyButtonPanel buttonPanel = (IMyButtonPanel)GridTerminalSystem.GetBlockWithName("Button"); string inputPassword = codeScreen.GetText(); if (inputPassword == passcode) { myDoor.OpenDoor(); acceptScreen.WriteText("Code Accepted"); } else { myDoor.CloseDoor(); } }
public Station(IMyButtonPanel panel) { this.panel = panel; }
public IMyButtonPanel findButtonPanelFromLCD(IMyTextPanel Panel) { IMyButtonPanel ButtonPanel = null; if (TryFindButtonPanel(new Vector3I(Panel.Position.X - 1, Panel.Position.Y, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X + 1, Panel.Position.Y, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X, Panel.Position.Y - 1, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X, Panel.Position.Y + 1, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X, Panel.Position.Y, Panel.Position.Z - 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X, Panel.Position.Y, Panel.Position.Z + 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X - 1, Panel.Position.Y - 1, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X - 1, Panel.Position.Y + 1, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X + 1, Panel.Position.Y - 1, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X + 1, Panel.Position.Y + 1, Panel.Position.Z), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X - 1, Panel.Position.Y - 1, Panel.Position.Z - 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X - 1, Panel.Position.Y + 1, Panel.Position.Z - 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X + 1, Panel.Position.Y - 1, Panel.Position.Z - 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X + 1, Panel.Position.Y + 1, Panel.Position.Z - 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X - 1, Panel.Position.Y - 1, Panel.Position.Z + 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X - 1, Panel.Position.Y + 1, Panel.Position.Z + 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X + 1, Panel.Position.Y - 1, Panel.Position.Z + 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } if (TryFindButtonPanel(new Vector3I(Panel.Position.X + 1, Panel.Position.Y + 1, Panel.Position.Z + 1), Panel.CubeGrid, out ButtonPanel)) { return(ButtonPanel); } return(ButtonPanel); }