} // Initialize() public bool Init0 () { int i; // counter Color computerColor = new Color(255, 69, 0); blockList.Clear(); // clear the block list GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(blockList, b => b.IsSameConstructAs(Me)); // get text panels cockpitLCD1 = null; cockpitLCD2 = null; for (i = 0; i < blockList.Count; i++) { if (blockList[i].CustomData.Contains(cockpitLCD1ID)) { cockpitLCD1 = blockList[i] as IMyTextPanel; } // if contains cockpitLCD1ID else if (blockList[i].CustomData.Contains(cockpitLCD2ID)) { cockpitLCD2 = blockList[i] as IMyTextPanel; } // else if contains cockpitLCD2ID } // for i if (cockpitLCD1 == null) { Echo("System: Unable to find LCD1\n"); } // if cockpitLCD1 == null else { cockpitLCD1.Enabled = true; //cockpitLCD1.Font = ""; cockpitLCD1.BackgroundColor = Color.Black; cockpitLCD1.FontColor = computerColor; cockpitLCD1.FontSize = 2.0f; cockpitLCD1.ShowPublicTextOnScreen(); cockpitLCD1.WritePublicTitle(cockpitLCD1Title); WriteLCD("LCD1 found.\n", 1); } // else cockpitLCD1 == null if (cockpitLCD2 == null) { Echo("System: Unable to find LCD2\n"); } // if cockpitLCD2 == null else { cockpitLCD2.Enabled = true; //cockpitLCD2.Font = ""; cockpitLCD2.BackgroundColor = Color.Black; cockpitLCD2.FontColor = computerColor; cockpitLCD2.FontSize = 2.0f; cockpitLCD2.ShowPublicTextOnScreen(); cockpitLCD2.WritePublicTitle(cockpitLCD2Title); WriteLCD("LCD2 found.\n", 2); } // else cockpitLCD2 == null return true; } // Init0()
public EasyBlock WritePublicTitle(string text) { IMyTextPanel textPanel = Block as IMyTextPanel; if (textPanel != null) { textPanel.WritePublicTitle(text); } return(this); }
public void progressPanels() { while (Runtime.CurrentInstructionCount < LOAD_LIMIT && PanelQueue.Count > 0) { panelProgressCount++; long panelId = PanelQueue.Dequeue().EntityId; IMyTextPanel Panel = GridTerminalSystem.GetBlockWithId(panelId) as IMyTextPanel; IMyTerminalBlock Cargo = getCargo(Panel); if (Panel != null && Panel is IMyTextPanel && Cargo != null && Panel.IsFunctional && Panel.IsWorking) { int fillLevel0 = 0; int fillLevel1 = 0; string fillBar = getFillLevelBarForBlock(Cargo, out fillLevel0, out fillLevel1); switch (Cargo.InventoryCount) { case 1: Panel.CustomData = getText("lcdStatSingleInventory", Cargo.CustomName, DateTime.Now, fillLevel0); Panel.WritePublicTitle(getText("lcdTitleStatSingle", fillLevel0, Cargo.CustomName)); break; case 2: Panel.CustomData = getText("lcdStatDoubleInventory", Cargo.CustomName, DateTime.Now, fillLevel0, fillLevel1); Panel.WritePublicTitle(getText("lcdTitleStatDouble", fillLevel0, fillLevel1, Cargo.CustomName)); break; } Panel.WritePublicText(fillBar); Panel.SetValueFloat("FontSize", fontSizeFuelBar); Panel.SetValue <long>("Font", fontIdMonospaced); Panel.ShowPublicTextOnScreen(); } else { Panel.WritePublicTitle(""); Panel.WritePublicText(getText("warnNoInventory")); Panel.SetValueFloat("FontSize", fontSizeText); Panel.SetValue <long>("Font", fontIdRed); Panel.ShowPublicTextOnScreen(); } } }
public void Main(string argument, UpdateType updateSource) { if (lcd != null) { lcd.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE; lcd.WriteText("Hello MyTextPanel\n"); lcd.WriteText("Status: OK", true); lcd.WritePublicTitle("my public title"); Echo("run OK"); } else { Echo("run ERROR"); } }
//SCRIPTINPUT (FS) void InitWindow() { window.ShowPublicTextOnScreen(); window.WritePublicTitle("Com Chat V1.0"); window.WritePublicText("Com Chat V1.0 \n\nList of known Ships in Com Distance :"); string info = window.DetailedInfo.Split('\n')[0]; if (info != "Type: Wide LCD panel") { width = 30; } knownShips.Add("Ship 1"); knownShips.Add("Ship 2"); knownShips.Add("Ship 3"); knownShips.Add("Ship 4"); UpdateChatWindow(); }
void Log(string text, IMyTextPanel lcd) { if (lcd != null) { if (text.Equals("clear")) { lcd.WritePublicText(""); lcd.WritePublicTitle(lcd.CustomName + " Status"); } else { string oldtext = lcd.GetPublicText(); lcd.ShowTextureOnScreen(); lcd.WritePublicText(oldtext + "\n" + text, false); } lcd.ShowPublicTextOnScreen(); } }
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 static void Add(IMyTextPanel block) { block.WritePublicTitle("API Key QR Code"); block.WritePrivateTitle("API Key String"); string black = ""; string white = ""; string key = ""; while (keyDict.ContainsKey(key = Generator.GenerateWeakKey(16))) { } block.WritePrivateText(key); keyDict.Add(key, block.EntityId); //Generate and write QR code. //TODO: Offload this functionality to client mod. QrEncoder q = new QrEncoder(ErrorCorrectionLevel.H); var code = q.Encode(key); if (code != null) { StringBuilder sb = new StringBuilder(); var bits = code.Matrix; for (int i = 0; i < bits.Width + 2; i++) { sb.Append(white); } sb.AppendLine(); for (int i = 0; i < bits.Height; i++) { sb.Append(white); for (int j = 0; j < bits.Width; j++) { if (bits.InternalArray[i, j]) { sb.Append(black); } else { sb.Append(white); } } sb.Append(white); sb.AppendLine(); } for (int i = 0; i < bits.Width + 2; i++) { sb.Append(white); } sb.AppendLine(); block.WritePublicText(sb.ToString()); block.ShowPublicTextOnScreen(); block.SetValueFloat("FontSize", 0.5f); block.SetValueColor("FontColor", new VRageMath.Color(120, 0, 0)); } }
public void Main(string argument, UpdateType updateSource) { Runtime.UpdateFrequency = UpdateFrequency.Update10; IMyTextPanel display = GridTerminalSystem.GetBlockWithName("LCD Panel [Status]") as IMyTextPanel; IMyBlockGroup hangarLights = GridTerminalSystem.GetBlockGroupWithName("Hangar Lights"); IMyBlockGroup hangarDoors = GridTerminalSystem.GetBlockGroupWithName("Hangar Doors"); List <IMyTerminalBlock> doors = new List <IMyTerminalBlock>(); hangarDoors.GetBlocksOfType <IMyAirtightHangarDoor>(doors); bool missing = false; if (hangarDoors == null) //Returns if doors not found { Echo("Doors not found"); missing = true; } List <IMyTerminalBlock> lights = new List <IMyTerminalBlock>(); hangarLights.GetBlocksOfType <IMyInteriorLight>(lights); if (hangarLights == null) //Returns if lights not found { Echo("Lights not found"); missing = true; } IMyTimerBlock timer = GridTerminalSystem.GetBlockWithName("[Hangar] Timer Block") as IMyTimerBlock; if (timer == null) //Returns if timer not found { Echo("Timer not found"); missing = true; } IMyAirVent vent = GridTerminalSystem.GetBlockWithName("[Hangar] Air Vent") as IMyAirVent; if (vent == null) //Returns if vent not found { Echo("Vent not found"); missing = true; } IMySoundBlock speaker = GridTerminalSystem.GetBlockWithName("[Hangar] Sound Block") as IMySoundBlock; if (speaker == null) //Returns if speaker not found { Echo("Speaker not found"); missing = true; } if (missing == true) { return; } UnifyLights(lights); //Turns all lights on speaker.SelectedSound = "Alert 1"; //Set speaker sound if (!timer.IsCountingDown) //Program will skip over if the timer is counting down { if (timer.TriggerDelay == 10) //Program will disable timer if the timer is set to 10 (end of hanagar door stage). { NormalLights(lights); display.FontSize = 4.4F; Echo("All is well"); display.WritePublicTitle("All is well"); timer.Enabled = true; timer.TriggerDelay = 15; speaker.LoopPeriod = 10; speaker.Stop(); Runtime.UpdateFrequency = UpdateFrequency.None; } else //Program will start hangar toggle process else wise { if (vent.CanPressurize && !vent.Depressurize) //If the vent needs to depressurize, start depressurize sequence { vent.Depressurize = true; timer.Enabled = true; timer.TriggerDelay = 15; timer.StartCountdown(); speaker.LoopPeriod = 25; speaker.Play(); WarningLights(lights); return; } WarningLights(lights); ToggleDoors(doors); display.FontSize = 3; Echo("!!!CAUTION!!!"); display.WritePublicTitle("!!!CAUTION!!!"); timer.TriggerDelay = 10; timer.StartCountdown(); vent.Depressurize = false; if (speaker.LoopPeriod != 25) { speaker.LoopPeriod = 10; speaker.Play(); } } } }
private void init() { #region initialization oldPBName = Me.CustomName; unique_id = (new Random()).Next(); all_blocks_found = true; autopilot_en = true; location_name = "UNKNOWN"; // For spinner counter = 0; string parse = Me.CustomName.Replace(BLOCK_PREFIX, ""); int id1 = Me.CustomName.IndexOf('['); int id2 = Me.CustomName.IndexOf(']'); if (id1 >= 0 && id2 >= 0) { parse = parse.Substring(id1 + 1, id2 - id1 - 1); } else { parse = ""; } BaconArgs Args = BaconArgs.parse(parse); IS_BASE = (Args.getFlag('b') > 0); DOCK_LEFT = (Args.getFlag('l') > 0); IS_PLANET = (Args.getFlag('p') > 0); if (IS_PLANET) { IS_BASE = true; } List <string> nameArg = Args.getOption("name"); if (nameArg.Count > 0 && nameArg[0] != null) { location_name = nameArg[0]; } // Set all known blocks to null or clear lists lcdPanel = null; messageReceiver = null; WANProgram = null; connector = null; remoteControl = null; door = null; timer = null; landLight = null; mainGear = 0; gyros.Clear(); destinations.Clear(); gears.Clear(); // Get all blocks List <IMyTerminalBlock> blks = new List <IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(BLOCK_PREFIX, blks, hasPrefix); num_blocks_found = blks.Count; // Assign blocks to variables as appropriate foreach (var blk in blks) { // LCD panel for printing if (blk is IMyTextPanel) { lcdPanel = blk as IMyTextPanel; lcdPanel.ShowPublicTextOnScreen(); lcdPanel.SetValueFloat("FontSize", 1.2f); } // Wico Area Network programmable block else if (blk is IMyProgrammableBlock && !blk.Equals(Me)) { WANProgram = blk as IMyProgrammableBlock; } // Autopilot else if (!IS_BASE && blk is IMyRemoteControl) { remoteControl = blk as IMyRemoteControl; } /* Ship or station connector for docking * Used to connect to station and for orientation info */ else if (!IS_PLANET && blk is IMyShipConnector) { connector = blk as IMyShipConnector; } /* Door used for docking; used for orientation information * since it's more obvious which way a door faces than a connector */ else if (!IS_PLANET && blk is IMyDoor) { door = blk as IMyDoor; } // Gyros for ship orientation else if (!IS_BASE && blk is IMyGyro) { IMyGyro g = blk as IMyGyro; gyros.Add(g); } // Timer block so that we can orient ship properly - requires multiple calls/sec else if (!IS_BASE && blk is IMyTimerBlock) { timer = blk as IMyTimerBlock; timer.SetValueFloat("TriggerDelay", 1.0f); } // Light (interior or spotlight) determines where we will land else if (IS_BASE && IS_PLANET && blk is IMyInteriorLight) { landLight = blk as IMyInteriorLight; } // Landing gear.... else if (!IS_BASE && blk is IMyLandingGear) { IMyLandingGear gear = blk as IMyLandingGear; gears.Add(gear); if (gear.CustomName.ToLower().Contains("main")) { mainGear = gears.Count - 1; } } } // Make sure all gyros reset resetGyros(); // Clear block list blks.Clear(); // Get text panel blocks used by Wico Area Network for communication GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(blks, hasWANRPrefix); if (blks.Count == 0) { Echo("Error: Can't find message received text panel for Wico Area Network"); all_blocks_found = false; } else { messageReceiver = blks[0] as IMyTextPanel; messageReceiver.WritePublicTitle(""); messageReceiver.WritePrivateTitle("NAV"); } if (WANProgram == null) { Echo("Error: Can't find programming block for Wico Area Network"); all_blocks_found = false; } if (lcdPanel == null) { Echo("Error: Expect 1 LCD"); all_blocks_found = false; } if (!IS_PLANET && connector == null) { Echo("Error: Can't find any connectors to use for docking"); all_blocks_found = false; } if (!IS_BASE && remoteControl == null) { Echo("Error: Can't find any remote control blocks"); all_blocks_found = false; } if (!IS_PLANET && door == null) { Echo("Error: Can't find door"); all_blocks_found = false; } if (!IS_BASE && gyros.Count == 0) { Echo("Error: No gyros detected"); all_blocks_found = false; } if (!IS_BASE && timer == null) { Echo("Error: No timer found"); all_blocks_found = false; } if (IS_PLANET && landLight == null) { Echo("Error: No light for landing ship destination found"); all_blocks_found = false; } if (!IS_BASE && gears.Count == 0) { Echo("Warning: no landing gear found. You will not be able to land on planets"); } // Init communicator state machine comm = communicate().GetEnumerator(); // Clear autopilot state machine fly = null; #endregion }
private void init() { #region initialization oldPBName = Me.CustomName; unique_id = (new Random()).Next(); all_blocks_found = true; autopilot_en = true; location_name = "UNKNOWN"; // For spinner counter = 0; string parse = Me.CustomName.Replace(BLOCK_PREFIX, ""); int id1 = Me.CustomName.IndexOf('['); int id2 = Me.CustomName.IndexOf(']'); if (id1 >= 0 && id2 >= 0) { parse = parse.Substring(id1 + 1, id2 - id1 - 1); } else { parse = ""; } BaconArgs Args = BaconArgs.parse(parse); IS_BASE = (Args.getFlag('b') > 0); DOCK_LEFT = (Args.getFlag('l') > 0); IS_PLANET = (Args.getFlag('p') > 0); if (IS_PLANET) IS_BASE = true; List<string> nameArg = Args.getOption("name"); if (nameArg.Count > 0 && nameArg[0] != null) { location_name = nameArg[0]; } // Set all known blocks to null or clear lists lcdPanel = null; messageReceiver = null; WANProgram = null; connector = null; remoteControl = null; door = null; timer = null; landLight = null; mainGear = 0; gyros.Clear(); destinations.Clear(); gears.Clear(); // Get all blocks List<IMyTerminalBlock> blks = new List<IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(BLOCK_PREFIX, blks, hasPrefix); num_blocks_found = blks.Count; // Assign blocks to variables as appropriate foreach (var blk in blks) { // LCD panel for printing if (blk is IMyTextPanel) { lcdPanel = blk as IMyTextPanel; lcdPanel.ShowPublicTextOnScreen(); lcdPanel.SetValueFloat("FontSize", 1.2f); } // Wico Area Network programmable block else if (blk is IMyProgrammableBlock && !blk.Equals(Me)) { WANProgram = blk as IMyProgrammableBlock; } // Autopilot else if (!IS_BASE && blk is IMyRemoteControl) { remoteControl = blk as IMyRemoteControl; } /* Ship or station connector for docking * Used to connect to station and for orientation info */ else if (!IS_PLANET && blk is IMyShipConnector) { connector = blk as IMyShipConnector; } /* Door used for docking; used for orientation information * since it's more obvious which way a door faces than a connector */ else if (!IS_PLANET && blk is IMyDoor) { door = blk as IMyDoor; } // Gyros for ship orientation else if (!IS_BASE && blk is IMyGyro) { IMyGyro g = blk as IMyGyro; gyros.Add(g); } // Timer block so that we can orient ship properly - requires multiple calls/sec else if (!IS_BASE && blk is IMyTimerBlock) { timer = blk as IMyTimerBlock; timer.SetValueFloat("TriggerDelay", 1.0f); } // Light (interior or spotlight) determines where we will land else if (IS_BASE && IS_PLANET && blk is IMyInteriorLight) { landLight = blk as IMyInteriorLight; } // Landing gear.... else if (!IS_BASE && blk is IMyLandingGear) { IMyLandingGear gear = blk as IMyLandingGear; gears.Add(gear); if (gear.CustomName.ToLower().Contains("main")) { mainGear = gears.Count - 1; } } } // Make sure all gyros reset resetGyros(); // Clear block list blks.Clear(); // Get text panel blocks used by Wico Area Network for communication GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(blks, hasWANRPrefix); if (blks.Count == 0) { Echo("Error: Can't find message received text panel for Wico Area Network"); all_blocks_found = false; } else { messageReceiver = blks[0] as IMyTextPanel; messageReceiver.WritePublicTitle(""); messageReceiver.WritePrivateTitle("NAV"); } if (WANProgram == null) { Echo("Error: Can't find programming block for Wico Area Network"); all_blocks_found = false; } if (lcdPanel == null) { Echo("Error: Expect 1 LCD"); all_blocks_found = false; } if (!IS_PLANET && connector == null) { Echo("Error: Can't find any connectors to use for docking"); all_blocks_found = false; } if (!IS_BASE && remoteControl == null) { Echo("Error: Can't find any remote control blocks"); all_blocks_found = false; } if (!IS_PLANET && door == null) { Echo("Error: Can't find door"); all_blocks_found = false; } if (!IS_BASE && gyros.Count == 0) { Echo("Error: No gyros detected"); all_blocks_found = false; } if (!IS_BASE && timer == null) { Echo("Error: No timer found"); all_blocks_found = false; } if (IS_PLANET && landLight == null) { Echo("Error: No light for landing ship destination found"); all_blocks_found = false; } if (!IS_BASE && gears.Count == 0) { Echo("Warning: no landing gear found. You will not be able to land on planets"); } // Init communicator state machine comm = communicate().GetEnumerator(); // Clear autopilot state machine fly = null; #endregion }