public void Output(string message)
 {
     if (tPanel != null)
     {
         tPanel.WriteText(message, false);
     }
 }
        public void Main(string argument, UpdateType updateSource)
        {
            // Echo("argument: " + argument);
            // Echo("updateSource: " + updateSource);

            if (lcd == null)
            {
                Echo("ERROR: need LCD");
            }
            else if (batteryList.Count == 0)
            {
                lcd.WriteText("ERROR: need BATTERY");
            }
            else
            {
                // отображаем заряд
                float CurrentStoredPowerSum = 0f;
                float MaxStoredPowerSum     = 0f;
                foreach (var battery in batteryList)
                {
                    CurrentStoredPowerSum += battery.CurrentStoredPower;
                    MaxStoredPowerSum     += battery.MaxStoredPower;
                }
                float value = (CurrentStoredPowerSum / MaxStoredPowerSum) * 100;
                lcd.WriteText(String.Format("{0:#}%", value));
            }
        }
Ejemplo n.º 3
0
        private void RunContinuousLogic()
        {
            if (_CheckBlock.IsFunctional && _CheckBlock.HasPlayerAccess(Me.OwnerId))
            {
                Echo($"Master: {_CheckBlock.CustomName}\nWorking\n");
            }
            else
            {
                GridTerminalSystem.GetBlocksOfType(_Warheads);
                Echo($"Master: {_CheckBlock.CustomName}\nBroken\nWarheads: {_Warheads.Count}\n");

                if (!countdown)
                {
                    countdown = true;
                    foreach (IMyWarhead warhead in _Warheads)
                    {
                        warhead.IsArmed        = true;
                        warhead.DetonationTime = TIME;
                        warhead.StartCountdown();
                    }
                    Runtime.UpdateFrequency = UpdateFrequency.None;
                    _LogOutput?.WriteText("\nRUN!!!", true);
                }
            }
        }
Ejemplo n.º 4
0
 internal void prepare()
 {
     block.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
     block.WriteText("");
     block.BackgroundColor = Color.Black;
     block.FontColor       = Color.White;
     block.FontSize        = 1.6F;
 }
Ejemplo n.º 5
0
        private void Display()
        {
            if (aligning)
            {
                mainLCD.ContentType = ContentType.TEXT_AND_IMAGE;
                mainLCD.Alignment   = TextAlignment.LEFT;
                mainLCD.FontColor   = Color.Gray;
                mainLCD.FontSize    = 1.3F;
                statusLCD.FontSize  = 10;
                mainLCD.WriteText(targetInfo);

                if (aligned)
                {
                    systemStatus = "Ready to jump";
                    statusLCD.BackgroundColor = Color.Green;
                }
                else
                {
                    systemStatus = "Aligning..."; mainLCD.ContentType = ContentType.TEXT_AND_IMAGE;
                    statusLCD.BackgroundColor = Color.Black;
                }
            }
            else
            {
                if (online)
                {
                    if (charging)
                    {
                        systemStatus = "Charging";
                        statusLCD.BackgroundColor = Color.Red;
                        mainLCD.WriteText("Remaining time: " + chargeTime);
                    }
                    else if (close && !aligned)
                    {
                        mainLCD.Alignment         = TextAlignment.CENTER;
                        systemStatus              = "Warning";
                        statusLCD.BackgroundColor = Color.MediumVioletRed;
                        mainLCD.WriteText("\n\n" + waypoints[selection].Name + "\n is only\n" + Math.Round(((cockpit.GetPosition() - Target).Length()) / 1000, 2) + " km away\n\n Please select \nan other destination\n");
                    }
                    else
                    {
                        systemStatus = "Standby";
                        statusLCD.BackgroundColor = Color.Black;
                        mainLCD.ContentType       = ContentType.TEXT_AND_IMAGE;
                        mainLCD.Alignment         = TextAlignment.CENTER;
                        mainLCD.WriteText(wayList);
                    }
                }
                else
                {
                    systemStatus = "Offline";
                    statusLCD.BackgroundColor = Color.Black;
                    mainLCD.WriteText("");
                }
            }

            statusLCD.WriteText(systemStatus);
        }
Ejemplo n.º 6
0
 public void Password(string argument)
 {
     if (LCD != null)
     {
         LCD.SetValueFloat("FontSize", PasswordFontSize);
         LCD.SetValueColor("FontColor", PasswordFontColor);
         LCD.SetValueColor("BackgroundColor", PasswordBackColor);
         LCD.WriteText(new String(PasswordCharacter, argument.Length), false);
     }
 }
Ejemplo n.º 7
0
 private Action <string> EchoTo(IMyTextPanel textPanel)
 {
     if (textPanel == null)
     {
         return _ => { }
     }
     ;
     textPanel.WriteText(string.Empty, false);
     return(text => textPanel.WriteText(text, true));
 }
 internal void prepare()
 {
     if (isDedicated)
     {
         block.WriteText("");
     }
     block.BackgroundColor = Color.Black;
     block.FontColor       = textColor;
     block.FontSize        = 1.6F;
 }
Ejemplo n.º 9
0
            private void DisplayInitialText()
            {
                if (_block == null)
                {
                    return;
                }

                _block.WriteText($"{About.ScriptName}\nDeveloped By: {About.ScriptAuthor}\nVersion: {About.ScriptVersion}");
                _block.WriteText($"\n-----------------------------------------------------", append: true);
                _block.WriteText("\n", append: true);
            }
Ejemplo n.º 10
0
        void UpdateDisplay()
        {
            StorageData ingotData = GetIngotsData();
            var         ingots    = from entry in ingotData.items orderby entry.Value descending select entry;

            panel.WriteText("Слитки:\n");
            foreach (var ingot in ingots)
            {
                panel.WriteText($"{GetTranslation(ingot.Key)}: {NormalizeFloat(ingot.Value)}\n", true);
            }
        }
Ejemplo n.º 11
0
 void Print(object message)
 {
     if (_debugScreen != null)
     {
         _debugScreen.WriteText(message + "\n", true);
     }
     else
     {
         Echo(message.ToString());
     }
 }
Ejemplo n.º 12
0
        void Main()
        {
            IMyInventory ContainerInventory = Container.GetInventory(0);

            ContainerInventory.GetItems(ContainerItems);
            LCD.WriteText("Cargo:\n", false);
            foreach (MyInventoryItem Item in ContainerItems)
            {
                LCD.WriteText("\n" + Item.Type.SubtypeId + ": " + Item.Amount, true);
            }
        }
Ejemplo n.º 13
0
 public void Main(string args)
 {
     extPanel.WriteText("");
     extPanel2.WriteText("111");
     Timer.StartCountdown();
     if (args == "Tick")
     {
         tickCount++;
         extPanel.WriteText("Tack " + tickCount);
     }
 }
Ejemplo n.º 14
0
    public void update()
    {
        var sb    = new StringBuilder();
        var lines = display.GetText().Split('\n');

        for (int i = Math.Max(lines.Length - maxLines, 0); i < lines.Length; i++)
        {
            sb.AppendLine(lines[i]);
        }

        display.WriteText(sb);
    }
Ejemplo n.º 15
0
 void UpdateDisplay(ReactorData reactorData, BatteryData batteryData)
 {
     panel.WriteText($"Реакторы: {(reactorData.status ? "вкл" : "выкл")}\n");
     panel.WriteText($"Кол-во реакторов:  {reactorData.count}\n", true);
     panel.WriteText($"Мощность:  {reactorData.power} МВт\n", true);
     panel.WriteText($"U в реакторах:        {reactorData.uraniumAmount:0.##} кг\n", true);
     panel.WriteText($"Авто-режим:       {(autoMode ? "вкл" : "выкл")}\n", true);
     panel.WriteText("-----------------------\n", true);
     panel.WriteText($"Заряд: {batteryData.percentage}%\n", true);
     panel.WriteText($"Кол-во:  {batteryData.count}\n", true);
     panel.WriteText($"Статус: {(batteryData.isCharging ? "зарядка" : "разрядка")}\n", true);
     panel.WriteText($"{(batteryData.isCharging ? "Эффективность заряда:" : "Эффективность разряда: ")}     { batteryData.powerRate}%\n", true);
 }
    //MyFunctions,Methods

    //Показывает текст из переменной на дисплее или очищает его.
    public void Display(string text, string lcdName, bool lcdClear = false)
    {
        IMyTextPanel myTextPanel = GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;

        if (!lcdClear)
        {
            myTextPanel.WriteText(text + "\r\n", true);
        }
        else
        {
            myTextPanel.WriteText("");
        }
    }
Ejemplo n.º 17
0
            public void DisplayAll()
            {
                if (Status == null)
                {
                    return;
                }

                Status.WriteText(header);

                lMKeys.ForEach(key =>
                {
                    Status.WriteText(lMessages[key], true);
                });
            }
Ejemplo n.º 18
0
        IMyTextPanel debug;                                                   //debug output

        public Program()
        {
            Echo("all is cool and good");
            me           = GridTerminalSystem.GetBlockWithName(meName) as IMyProgrammableBlock; //programmable block running script
            connectorIn  = GridTerminalSystem.GetBlockWithName(connectorInName) as IMyShipConnector;
            connectorOut = GridTerminalSystem.GetBlockWithName(connectorOutName) as IMyShipConnector;
            debug        = GridTerminalSystem.GetBlockWithName(debugPanelName) as IMyTextPanel; //debug output
            debug.WriteText("");                                                                //Clear debug
            populateInventoriesList();                                                          //populates list with local inventories

            Runtime.UpdateFrequency = UpdateFrequency.Update100;                                //program runs every 100 ticks
            //debugging stuff
            debug.WriteText("" + inventories.Count);
        }
 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");
     }
 }
Ejemplo n.º 20
0
        public void UpdateLCD()
        {
            _LogOutput?.WriteText($"{_LcdOutput}", false);

            _LogOutput?.WriteText($"Not extended Pistons: {_Pistons.Count}\n", true);
            _LogOutput?.WriteText($"Extended Pistons: {_ExtendedPistons.Count}\n", true);
            _LogOutput?.WriteText($"Rotor Movment: {_RotorMoved}\n", true);
            _LogOutput?.WriteText($"Rotor last angle: {_RotorLastAngle}\n", true);
            _LogOutput?.WriteText($"Rotor current angle: {_Rotor.Angle}\n", true);
            _LogOutput?.WriteText($"CurrentInstructionCount: {Runtime.CurrentInstructionCount}\n", true);
            _LogOutput?.WriteText($"\nDrill status: {_Status}", true);
        }
Ejemplo n.º 21
0
        public Dictionary <string, int> GetRequiredComponents()
        {
            IMyTextPanel panel  = GridTerminalSystem.GetBlockWithName("TXTPNL") as IMyTextPanel;
            var          blocks = Projector.RemainingBlocksPerType;

            char[] delimiters = new char[] { ',' };
            char[] remove     = new char[] { '[', ']' };
            Dictionary <string, int> totalComponents = new Dictionary <string, int>();

            foreach (var item in blocks)
            {
                string[] blockInfo = item.ToString().Trim(remove).Split(delimiters, StringSplitOptions.None);
                try
                {
                    string blockName = blockInfo[0];
                    int    amount    = Convert.ToInt32(blockInfo[1]);

                    BlueprintDefinitions.AddComponents(totalComponents, BlueprintDefinitions.GetBlockComponents(blockName), amount);
                }
                catch (Exception ex)
                {
                    GridProgram.Echo($"Error in GetRequiredComponent() at {blockInfo[0]}:{blockInfo[1]} => {ex.Message}");
                }
                // blockInfo[0] is blueprint, blockInfo[1] is number of required item
            }
            string output = "";

            foreach (KeyValuePair <string, int> component in totalComponents)
            {
                output += component.Key.Replace("MyObjectBuilder_BlueprintDefinition/", "") + " " + component.Value.ToString() + "\n";
            }
            panel.WriteText(output);
            return(totalComponents);
        }
Ejemplo n.º 22
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (lcd != null)
            {
                stringBuilder.Clear();
                stringBuilder.Append("count: " + list.Count());
                foreach (var item in list)
                {
                    stringBuilder.Append("\n" + item.CustomName); // Программируемый блок 5
                    // stringBuilder.Append("\n  IsRunning: " + item.IsRunning); // true
                    // stringBuilder.Append("\n  TerminalRunArgument: " + item.TerminalRunArgument); // это аргумент по-умолчанию
                    // stringBuilder.Append("\n  Position: " + item.Position.X + ", " + item.Position.Y + ", " + item.Position.Z); // 1, -4, 0
                    // stringBuilder.Append("\n" + item.GetId()); // 96243392444855564
                    // stringBuilder.Append("\n" + item.EntityId); // 96243392444855564
                    // stringBuilder.Append("\n" + item.DisplayNameText); // Программируемый блок 5
                    // stringBuilder.Append("\n" + item.DisplayName); // пусто
                    // stringBuilder.Append("\n" + item.DetailedInfo); // пусто
                    // stringBuilder.Append("\n" + item.Name); // 96243392444855564
                }
                lcd.WriteText(stringBuilder.ToString());

                // отправляем команду
                var pb     = list[1];
                var result = pb.TryRun("hello PB");
                Echo("TryRun result: " + result);

                Echo("run OK");
            }
            else
            {
                Echo("run ERROR");
            }
        }
Ejemplo n.º 23
0
        private void SwitchHugeLCD(string subPanelNumber)
        {
            IMyTextPanel mainPanel = (IMyTextPanel)GridTerminalSystem.GetBlockWithName($"{hugeLCDName}");
            IMyTextPanel subPanel  = (IMyTextPanel)GridTerminalSystem.GetBlockWithName($"{hugeLCDName} {subPanelNumber}");

            mainPanel.WriteText(subPanel.GetText());
        }
Ejemplo n.º 24
0
        public Program()
        {
            Load();

            // Grinder Arm Blocks
            _grindArmRotor            = GetBlockOrThrow <IMyMotorStator>("Grinder Rotor");
            _grindArmHinge            = GetBlockOrThrow <IMyMotorStator>("Grinder Hinge");
            _grindArmPistonVert       = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Vert");
            _grindArmPistonHoriz      = GetBlockOrThrow <IMyPistonBase>("Grinder Piston Horiz");
            _grindArmPistonPark       = GetBlockOrThrow <IMyPistonBase>("Grinder Park Piston");
            _grindArmLandingGearGroup = GetGroupOrThrow("Grinder Landing Gear");

            // Drill Blocks
            _drillPistonGroup       = GetGroupOrThrow("Drill Pistons");
            _drillGroup             = GetGroupOrThrow("Drills");
            _drillWelderGroup       = GetGroupOrThrow("Welders");
            _drillMergeBlock        = GetBlockOrThrow <IMyShipMergeBlock>("Drill Merge Block");
            _drillConnector         = GetBlockOrThrow <IMyShipConnector>("Drill Connector");
            _drillSupportMergeBlock = GetBlockOrThrow <IMyShipMergeBlock>("Support Merge Block");
            _drillProjector         = GetBlockOrThrow <IMyProjector>("Drill Projector");

            // LCD setup
            _lcd = GetBlockOrThrow <IMyTextPanel>("Drill Rig LCD");
            if (_lcd != null)
            {
                Echo("Found LCD");
                _lcd.ContentType = ContentType.TEXT_AND_IMAGE;
                _lcd.FontSize    = 0.5f;
                _lcd.FontColor   = new Color(200, 200, 200); // less bright white is also less blurry
                _lcd.Alignment   = TextAlignment.LEFT;
                _lcd.WriteText("Drill Rig Debug Logs");      // Clear all text
            }
        }
Ejemplo n.º 25
0
 private void Print(string text, string tag = "")
 {
     if ((text != null) && (tag != null))
     {
         GridTerminalSystem.GetBlocks(blocks);
         foreach (IMyTerminalBlock block in blocks)
         {
             if ((block is IMyTextPanel) && (block.CustomData.Trim() == tag))
             {
                 IMyTextPanel text_panel = (IMyTextPanel)block;
                 text_panel.WriteText(text, true);
                 text_panel.WriteText("\n", true);
             }
         }
     }
 }
Ejemplo n.º 26
0
 private void Print(string mode, string message)
 {
     if (panel != null)
     {
         messages.Add(String.Join("", String.Format("{0:0.00}", myProgram.Runtime.LastRunTimeMs), " [", mode, "] ", message, "\n"));
         if (messages.Count > 20)
         {
             messages.RemoveAt(0);
         }
         panel.WriteText("", false);
         foreach (string content in messages)
         {
             panel.WriteText(content, true);
         }
     }
 }
Ejemplo n.º 27
0
    //Показывает текст из переменной на дисплее или очищает его.
    public void Display(string text, string lcdName, bool lcdClear = false)
    {
        IMyTextPanel myTextPanel = GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;

        if (!lcdClear)
        {
            StringBuilder sb = new StringBuilder();
            myTextPanel.ReadText(sb);
            sb.AppendLine(text);
            myTextPanel.WriteText(sb + "\r\n");
        }
        else
        {
            myTextPanel.WriteText("");
        }
    }
Ejemplo n.º 28
0
        public Program()
        {
            #region Constructor Help

            /* The constructor, called only once every session and
             * // always before any other method is called. Use it to
             * // initialize your script.
             * //
             * // The constructor is optional and can be removed if not
             * // needed.
             * //
             * // It's recommended to set RuntimeInfo.UpdateFrequency
             * // here, which will allow your script to run itself without a
             * timer block.*/
            #endregion

            _timer      = GridTerminalSystem.GetBlockWithName("MRF_Timer") as IMyTimerBlock;
            _lOn        = GridTerminalSystem.GetBlockWithName("MRF_lOn") as IMyInteriorLight;
            _lOff       = GridTerminalSystem.GetBlockWithName("MRF_lOff") as IMyInteriorLight;
            _rotor      = GridTerminalSystem.GetBlockWithName("MRF_Rotor") as IMyMotorStator;
            _debugPanel = GridTerminalSystem.GetBlockWithName("MRF_Debug") as IMyTextPanel;

            SetDrills();
            _debugPanel.WriteText(string.Join(",", _drills.Select(d => d.Name)));
        }
Ejemplo n.º 29
0
        void Main(string args)
        {
            if (args == "start")
            {
                startFlag = true;
                LCD.WriteText("start flag\n");
                Runtime.UpdateFrequency = UpdateFrequency.Update100;
            }

            if (args == "stop")
            {
                startFlag = false;
                Runtime.UpdateFrequency = UpdateFrequency.None;
                LCD.WriteText("start flag\n");
            }
        }
Ejemplo n.º 30
0
        // TODO: display n to m lines.
        public void UpdatePublic(bool show = true)
        {
            try
            {
                if (FontSize != _panel.FontSize)
                {
                    _panel.FontSize = FontSize;
                }
            }
            catch (Exception ex)
            {
                // The game may generate an exception from the GetValueFloat(GetValue) call.
                // We can safely ignore this if it doesn't work, but it may indicate a game issue.
                EconomyScript.Instance.ServerLogger.WriteException(ex, UpdateCrashMessage);
                EconomyScript.Instance.ClientLogger.WriteException(ex, UpdateCrashMessage);
            }

            LastUpdate = DateTime.Now;

            // no need to update if the text has not changed.
            if (_panel.GetText() != _publicString.ToString())
            {
                _panel.WriteText(_publicString.ToString());

                if (show)
                {
                    _panel.ContentType = ContentType.TEXT_AND_IMAGE;
                }
            }
        }