Exemplo n.º 1
39
 public static void Log(string logMessage, Action<string> echo = null, IMyProgrammableBlock me = null, string label = null, IMyTextPanel mirrorLcd = null, bool truncateForLcd = true)
 {
     String output = "";
     if(echo == null) {
         output = "\n";
         output += logMessage;
         throw new Exception(output);
     }
     if(LogBuffer == null) {
         LogBuffer = new StringBuilder();
     }
     if(label != null) {
         logMessage = label+": "+logMessage;
     }
     if(mirrorLcd != null) {
         string currentlyMirrored = mirrorLcd.GetPublicText();
         if(truncateForLcd && LogBuffer.Length + logMessage.Length > LOG_MAX_LCD_LENGTH_CHARS) {
             StringBuilder lcdBuffer = new StringBuilder(LogBuffer.ToString());
             int charAmountToOffset = fullLineCharsExceeding(lcdBuffer, logMessage.Length, LogBuffer.Length - (LOG_MAX_LCD_LENGTH_CHARS - logMessage.Length));
             lcdBuffer.Remove(0, LogBuffer.Length - LOG_MAX_LCD_LENGTH_CHARS + charAmountToOffset - 2);
             lcdBuffer.AppendLine();
             lcdBuffer.Append(logMessage);
             mirrorLcd.WritePublicText(lcdBuffer.ToString(), false);
         } else {
             string potentialNewLine = (currentlyMirrored.Length > 0)? "\n" : "";
             mirrorLcd.WritePublicText(potentialNewLine+logMessage, true);
         }
     }
     if(LogBuffer.Length + logMessage.Length * 2 > LOG_MAX_ECHO_LENGTH_CHARS) {
         int charAmountToRemove = fullLineCharsExceeding(LogBuffer, logMessage.Length);
         LogBuffer.Remove(0, charAmountToRemove);
         LogBuffer.Append(output);
     }
     if(LogBuffer.Length > 0) {
         LogBuffer.AppendLine();
     }
     LogBuffer.Append(logMessage);
     echo(LogBuffer.ToString());
 }
Exemplo n.º 2
0
        public void Main(string containerName)
        {
            IMyCargoContainer cargo = FindBlock <IMyCargoContainer>(containerName);
            IMyTextPanel      debug = FindBlock <IMyTextPanel>("debug");

            if (cargo == null || debug == null)
            {
                debug.WritePublicText("Cargo or debug not found!", false);
                return;
            }
            IMyInventory cargoInventory = cargo.GetInventory(0);

            var assemblers = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyAssembler>(assemblers);
            for (int i = 0; i < assemblers.Count; i++)
            {
                if (!assemblers[i].HasInventory)
                {
                    continue;
                }
                IMyInventory            inventory = assemblers[i].GetInventory(1);
                List <IMyInventoryItem> items     = inventory.GetItems();
                debug.WritePublicText("Items Moved:" + items.Count + "\n", true);
                // Move items to cargo
                for (int j = 0; j < items.Count; j++)
                {
                    inventory.TransferItemTo(cargoInventory, 0, null, stackIfPossible: true);
                }
            }
        }
 private void AddEntriesToPanel(IMyTextPanel Panel)
 {
     if (Autoscroll)
     {
         List <string> buffer = new List <string>(Panel.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries));
         buffer.AddRange(Queue);
         int maxLines = Math.Min(getMaxLinesFromPanel(Panel), buffer.Count);
         if (Prepend)
         {
             buffer.Reverse();
         }
         Panel.WritePublicText(string.Join("\n", buffer.GetRange(buffer.Count - maxLines, maxLines).ToArray()), false);
     }
     else
     {
         if (Prepend)
         {
             var buffer = new List <string>(Panel.GetPublicText().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries));
             buffer.AddRange(Queue);
             buffer.Reverse();
             Panel.WritePublicText(string.Join("\n", buffer.ToArray()), false);
         }
         else
         {
             Panel.WritePublicText(string.Join("\n", Queue.ToArray()), true);
         }
     }
 }
 /// <summary>
 /// Using single LCD mode
 /// </summary>
 private void Single_Docking()
 {
     if (G_LCD != null)
     {
         G_LCD.WritePublicText($"<---Ship Status--->\nLocked: {Get_Amount_Connected ()}/{connectors.Count}\n", true);
     }
 }
Exemplo n.º 5
0
}         // программ

public void Main(string argument)
{
    if (argument == "stop")
    {
        return;
    }
    else
    {
        Runtime.UpdateFrequency = UpdateFrequency.Update100;
    }

    // разпознавание присутствия хозяина в кокпите
    if (memcocpit != cocpit.IsUnderControl)
    {
        memcocpit = cocpit.IsUnderControl;
        if (memcocpit)
        {
            DBG.WritePublicText("Вошол\n", true);
        }
        else
        {
            DBG.WritePublicText("Вышел\n", true);
        }
    }
}
Exemplo n.º 6
0
        private void printDetectedObjects()
        {
            var det = new List <MyDetectedEntityInfo>();

            foreach (IMySensorBlock sensor in sensors)
            {
                det.Clear();
                sensor.DetectedEntities(det);
                if (lcd != null)
                {
                    lcd.WritePublicText("Detected " + det.Count + " entities.\n", false);
                }

                foreach (var d in det)
                {
                    if (lcd != null)
                    {
                        lcd.WritePublicText("ID: " + d.EntityId + "\n", true);
                        lcd.WritePublicText("Name: " + d.Name + "\n", true);
                        lcd.WritePublicText("Type: " + d.Type + "\n", true);
                        lcd.WritePublicText("Time(ms): " + d.TimeStamp + "\n", true);
                        lcd.WritePublicText("Orientation: " + d.Orientation + "\n", true);
                        lcd.WritePublicText("BB: " + d.BoundingBox + "\n", true);
                        lcd.WritePublicText("Vel: " + d.Velocity + "\n", true);

                        lcd.WritePublicText("Pos: " + convertToGPS("Player", d.Position) + "\n", true);
                        lcd.WritePublicText("Relation: " + d.Relationship + "\n", true);
                    }
                }
            }
        }
Exemplo n.º 7
0
// ***MARKER: State Machine Program
// NOTE: If you don't need a precreated, reusable state machine,
// replace the declaration with the following:
// public IEnumerator<bool> RunStuffOverTime() {
    public IEnumerable <bool> RunStuffOverTime()
    {
        // For the very first instruction set, we will just switch on the light.
        _panelLight.RequestEnable(true);

        // Then we will tell the script to stop execution here and let the game do it's
        // thing. The time until the code continues on the next line after this yield return
        // depends  on your State Machine Execution and the timer setup.
        // I have chosen the simplest form of state machine here. A return value of
        // true will tell the script to execute the next step the next time the timer is
        // invoked. A return value of false will tell the script to halt execution and not
        // continue. This is actually not really necessary, you could have used the
        // statement
        //      yield break;
        // to do the same. However I wanted to demonstrate how you can use the return
        // value of the enumerable to control execution.
        yield return(true);

        int i = 0;

        // The following would seemingly be an illegal operation, because the script would
        // keep running until the instruction count overflows. However, using yield return,
        // you can get around this limitation.
        while (true)
        {
            _textPanel.WritePublicText(i.ToString());
            i++;
            // Like before, when this statement is executed, control is returned to the game.
            // This way you can have a continuously polling script with complete state
            // management, with very little effort.
            yield return(true);
        }
    }
Exemplo n.º 8
0
public Program()
{
    DBG = GridTerminalSystem.GetBlockWithName("DBG") as IMyTextPanel;
    DBG.ShowPublicTextOnScreen();
    DBG.WritePublicText("Отладочная консоль\n", false);

    List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>();

    GridTerminalSystem.GetBlocksOfType <IMyLightingBlock>(blocks);

    initLight(blocks);         // настройка всех ламп и прожекторов

    // создать группу
    //IMyBlockGroup group = GridTerminalSystem.GetBlockGroupWithName( "Группа");


    // печать имён всех групп корабля
    List <IMyBlockGroup> groups = new List <IMyBlockGroup>();

    GridTerminalSystem.GetBlockGroups(groups);
    foreach (IMyBlockGroup tut in groups)
    {
        DBG.WritePublicText(tut.Name.ToString() + "\n", true);
    }

    Echo("Вывод в терминал программного блока");

    // разпознавание присутствия хозяина в кокпите
    cocpit = GridTerminalSystem.GetBlockWithName("Кабина") as IMyCockpit;
}         // программ
Exemplo n.º 9
0
 void StatusLog(string text, IMyTextPanel block, bool bReverse = false)
 {
     if (block == null)
     {
         return;
     }
     if (text.Equals("clear"))
     {
         block.WritePublicText("");
     }
     else
     {
         if (bReverse)
         {
             string oldtext = block.GetPublicText();
             block.WritePublicText(text + "\n" + oldtext);
         }
         else
         {
             block.WritePublicText(text + "\n", true);
         }
         // block.WritePublicTitle(DateTime.Now.ToString());
     }
     block.ShowTextureOnScreen();
     block.ShowPublicTextOnScreen();
 }
        private void Log(string text)
        {
            return;

            string line = text; //Logger.Log(text);

            MyAPIGateway.Utilities.ShowMessage("TR-Log", line);

            if (LcdPanel == null)
            {
                return;
            }

            List <string> output = new List <string>();

            output.AddArray(LcdPanel.GetPublicText().Split('\n'));
            if (output.Count > 17)
            {
                while (output.Count > 16)
                {
                    output.RemoveAt(0);
                }

                LcdPanel.WritePublicText(string.Join("\n", output.ToArray()));
            }

            LcdPanel.WritePublicText(line + "\n", true);
        }
Exemplo n.º 11
0
        void Main(string argument)
        {
            if (s == null)
                s = GridTerminalSystem.GetBlockWithName("Data - Power") as IMyTextPanel;
            if (solars.Count == 0)
                GridTerminalSystem.GetBlocksOfType<IMySolarPanel>(solars);
            Echo("Checking Grids");
            Echo("Found " + solars.Count + " pannels attached");
            /*solars = solars.FindAll(delegate (IMySolarPanel c) 
            { 
                if(c.CubeGrid.ToString() == s.CubeGrid.ToString())
                    return true;
                return false;
            });*/
            int count = solars.Count;
            Echo("Filtered to " + count + " panels");
            if (argument == "reset" || count != lastCount)
            {
                peakPower = 0;
                totalPower = 0;
                minPower = -1;
                cycles = 0;
            }
            lastCount = count;
            float total = 0;
            cycles++;
            Echo("Cycle #" + cycles + " Started");
            int panel_count = 0;
            Echo("Going to check " + count + " panels");
            for (int i = 0; i < count; i++)
            {
                total += solars[i].MaxOutput;
                panel_count++;
            }
            if (peakPower < total)
                peakPower = total;
            if (minPower == -1 || minPower > total)
                minPower = total;
            totalPower += total;
            string f_peakPower = "None";
            if (peakPower > 0)
                f_peakPower = FormatNumber(peakPower * Math.Pow(1000, 2)) + "W";
            string f_minPower = "None";
            if (minPower > 0)
                f_minPower = FormatNumber(minPower * Math.Pow(1000, 2)) + "W";
            string f_averagePower = "None";
            if (totalPower > 0)
                f_averagePower = FormatNumber(totalPower / cycles * Math.Pow(1000, 2)) + "W";

            s.WritePublicText("Peak Power:\n" + f_peakPower + "\n");
            s.WritePublicText("Min Power:\n" + f_minPower + "\n", true);
            s.WritePublicText("Average Power:\n" + f_averagePower + "\n", true);
            s.WritePublicText("For " + panel_count + " Panels" + "\n", true);
            Echo("Peak Power: " + f_peakPower);
            Echo("Min Power: " + f_minPower);
            Echo("Average Power: " + f_averagePower);
            Echo("For " + panel_count + " Panels");
            Echo("Cycle #" + cycles + " Completed");
        }
Exemplo n.º 12
0
 public void BindLCD(IMyTextPanel txtpnl)
 {
     if (Panel != null)
     {
         Panel.WritePublicText("MENU UNBOUND");
     }
     Panel = txtpnl;
     UpdateLCD();
 }
 public void WriteDebug(string message, params object[] args)
 {
     if (debugScreen == null)
     {
         return;
     }
     debugScreen.WritePublicText(String.Format(message, args), true);
     debugScreen.WritePublicText("\n", true);
 }
Exemplo n.º 14
0
        //------------------------------------------------------------------------

        public void Main(string argument, UpdateType updateSource)
        {
            if (GetShipSystems())
            {
                //------------------------------------------------------------------
                // Environment
                //------------------------------------------------------------------

                m_textPanel.WritePublicText("");

                m_listError.Clear();

                m_argument     = argument;
                m_updateSource = updateSource;
                m_dateTimeNow  = DateTime.Now;

                m_currentPosition = Me.CubeGrid.GridIntegerToWorld(Me.Position);

                //------------------------------------------------------------------

                DrawText("//--------------------------------------------");
                DrawText("// ASSEMBLER2000 BY VX TEK AUTOMATING SYSTEMS ");
                DrawText("//--------------------------------------------");
                DrawText("");

                DrawText("Date " + m_dateTimeNow.ToShortDateString() + " " + m_dateTimeNow.ToLongTimeString());

                DrawText("Current position  : " + m_currentPosition.X + ":" + m_currentPosition.Y + ":" + m_currentPosition.Z);
                DrawText("Last position     : " + m_lastPosition.X + ":" + m_lastPosition.Y + ":" + m_lastPosition.Z);

                DrawText("Current ship speed: " + Vector3D.Distance(m_lastPosition, m_currentPosition));

                //------------------------------------------------------------------
                // State machine
                //------------------------------------------------------------------

                switch (m_internalState)
                {
                case EInternalState.Idle: { StateIdle(); } break;

                case EInternalState.Assembling: { StateAssembling(); } break;

                case EInternalState.Error: { StateAssembling(); } break;
                }
            }
            else
            {
                m_internalState = EInternalState.Error;
            }
        }
Exemplo n.º 15
0
    public static void Log(string logMessage, Action <string> echo = null, IMyProgrammableBlock me = null, string label = null, IMyTextPanel mirrorLcd = null, bool truncateForLcd = true)
    {
        String output = "";

        if (echo == null)
        {
            output  = "\n";
            output += logMessage;
            throw new Exception(output);
        }
        if (LogBuffer == null)
        {
            LogBuffer = new StringBuilder();
        }
        if (label != null)
        {
            logMessage = label + ": " + logMessage;
        }
        if (mirrorLcd != null)
        {
            string currentlyMirrored = mirrorLcd.GetPublicText();
            if (truncateForLcd && LogBuffer.Length + logMessage.Length > LOG_MAX_LCD_LENGTH_CHARS)
            {
                StringBuilder lcdBuffer          = new StringBuilder(LogBuffer.ToString());
                int           charAmountToOffset = fullLineCharsExceeding(lcdBuffer, logMessage.Length, LogBuffer.Length - (LOG_MAX_LCD_LENGTH_CHARS - logMessage.Length));
                lcdBuffer.Remove(0, LogBuffer.Length - LOG_MAX_LCD_LENGTH_CHARS + charAmountToOffset - 2);
                lcdBuffer.AppendLine();
                lcdBuffer.Append(logMessage);
                mirrorLcd.WritePublicText(lcdBuffer.ToString(), false);
            }
            else
            {
                string potentialNewLine = (currentlyMirrored.Length > 0)? "\n" : "";
                mirrorLcd.WritePublicText(potentialNewLine + logMessage, true);
            }
        }
        if (LogBuffer.Length + logMessage.Length * 2 > LOG_MAX_ECHO_LENGTH_CHARS)
        {
            int charAmountToRemove = fullLineCharsExceeding(LogBuffer, logMessage.Length);
            LogBuffer.Remove(0, charAmountToRemove);
            LogBuffer.Append(output);
        }
        if (LogBuffer.Length > 0)
        {
            LogBuffer.AppendLine();
        }
        LogBuffer.Append(logMessage);
        echo(LogBuffer.ToString());
    }
 public void c_log(string message)
 {
     if (logPanel == null)
     {
         return;
     }
     if (message == null)
     {
         logPanel.WritePublicText("");
     }
     else
     {
         logPanel.WritePublicText(message + "\n", true);
     }
     logPanel.ShowPublicTextOnScreen();
 }
Exemplo n.º 17
0
        // TODO: display n to m lines.
        public void UpdatePublic(bool show = true)
        {
            try
            {
                if (FontSize != _panel.GetValueFloat("FontSize"))
                {
                    _panel.SetValueFloat("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.GetPublicText() != _publicString.ToString())
            {
                _panel.WritePublicText(_publicString.ToString());

                if (show)
                {
                    if (ForceRedraw)
                    {
                        _panel.ShowTextureOnScreen();
                    }
                    _panel.ShowPublicTextOnScreen();
                }
            }
        }
        public void Main(string argument)
        {
            // The main entry point of the script, invoked every time
            // one of the programmable block's Run actions are invoked.
            //
            // The method itself is required, but the argument above
            // can be removed if not needed.


            BMyLog4PB Log = new BMyLog4PB(this, BMyLog4PB.E_ALL, new BMyLog4PB.BMyTextPanelAppender("DrawLog", this));

            Log.AutoFlush = true;

            IMyTextPanel panel = GridTerminalSystem.GetBlockWithName("DrawPanel") as IMyTextPanel;

            if (panel == null)
            {
                throw new Exception("Panel \"DrawPanel\" not found");
            }

            string[] code = panel?.CustomData.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

            Log?.PushStack("BaconDraw");
            string image = (new BaconDraw()).run(code, Log).ToString();

            Log.PopStack();
            panel?.WritePublicText(image);
            panel?.ShowPublicTextOnScreen();
        }
Exemplo n.º 19
0
        private void debug(string line, int logLevel = LOG_LVL_DEBUG)
        {
            if (usedLogLevel != LOG_LVL_SILENT)
            {
                if (usedLogLevel >= logLevel)
                {
                    string prefix = "";
                    if (usedLogLevel >= LOG_LVL_DEBUG)
                    {
                        prefix = "[Tick#" + this.ElapsedTime.Ticks.ToString() + "]";
                    }

                    line = prefix + line;

                    Echo(line.Trim());

                    List <IMyTerminalBlock> LCDs = new List <IMyTerminalBlock>();
                    GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(LCDs, (x => x.CustomName.Contains(TAG_LOG_DEBUG_LCD) && x.CubeGrid.Equals(Me.CubeGrid)));

                    for (int i = 0; i < LCDs.Count; i++)
                    {
                        IMyTextPanel  LCD = LCDs[i] as IMyTextPanel;
                        StringBuilder sb  = new StringBuilder();
                        sb.AppendLine(line);
                        sb.Append(LCD.GetPublicText());
                        LCD.WritePublicText(sb.ToString());
                    }
                }
            }
        }
Exemplo n.º 20
0
 public void Main(string argument, UpdateType updateSource)
 {
     str = "";
     if (Me.CustomData == "0")
     {
         foreach (var th in thrusters)
         {
             IMyThrust thr = th as IMyThrust;
             th.ApplyAction("OnOff_On");
             thr.ThrustOverridePercentage = 0;
         }
         foreach (var item in Gyros)
         {
             item.GyroOverride = false;
         }
     }
     else
     {
         foreach (var th in thrusters)
         {
             IMyThrust thr = th as IMyThrust;
             thrusterControllr(thr);
         }
         gyroControll();
     }
     text.WritePublicText(str);
     Echo(Me.CustomData);
 }
Exemplo n.º 21
0
        // ***MARKER: Coroutine Example
        // The return value (bool in this case) is not important for this example. It is not
        // actually in use.
        public IEnumerator <bool> RunStuffOverTime()
        {
            // For the very first instruction set, we will just switch on the light.
            _panelLight.Enabled = true;

            // Then we will tell the script to stop execution here and let the game do it's
            // thing. The time until the code continues on the next line after this yield return
            // depends  on your State Machine Execution and the timer setup.
            // The `true` portion is there simply because an enumerator needs to return a value
            // per item, in our case the value simply has no meaning at all. You _could_ utilize
            // it for a more advanced scheduler if you want, but that is beyond the scope of this
            // tutorial.
            yield return(true);

            int i = 0;

            // The following would seemingly be an illegal operation, because the script would
            // keep running until the instruction count overflows. However, using yield return,
            // you can get around this limitation - without breaking the rules and while remaining
            // performance friendly.
            while (i < 100)
            {
                i++;
                _textPanel.WritePublicText(argument + " " + i.ToString());
                // Like before, when this statement is executed, control is returned to the game.
                // This way you can have a continuously polling script with complete state
                // management, with very little effort.
                yield return(true);
            }
        }
Exemplo n.º 22
0
 public void update()
 {
     if (ready)
     {
         screen.WritePublicText(new String(data), false);
     }
 }
Exemplo n.º 23
0
        public void Main(string argument)
        {
            List <IMyTextPanel> TTYs = new List <IMyTextPanel>();

            GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(TTYs, (IMyTextPanel x) => x.CustomName.Contains("TTY") && x.CubeGrid.Equals(Me.CubeGrid));
            BaconShell.Environment env = new BaconShell.Environment(this, GridTerminalSystem, new BaconDebug("debug", GridTerminalSystem, this, 99));
            BaconShell             bs  = new BaconShell(env);

            for (int i_TTY = 0; i_TTY < TTYs.Count; i_TTY++)
            {
                IMyTextPanel TTY   = TTYs[i_TTY];
                string       stdin = TTY.GetPrivateText();
                if (!stdin.Equals(""))
                {
                    StringBuilder stdout  = new StringBuilder();
                    string[]      command = stdin.Split(new Char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < command.Length; i++)
                    {
                        BaconArgs Args = BaconArgs.parse(command[i]);
                        stdout.Append(bs.runCommand(Args, env).ToString());
                    }
                    TTY.WritePrivateText("");
                    TTY.WritePublicText(stdout.ToString());
                }
            }
        }
Exemplo n.º 24
0
            } // AddLog method

            public void Update()
            {
                const string title = "Log File\n"; // Screen Title

                int    i    = 0;                   // loop counter
                string temp = "";                  // temp string

                if (log == "")
                {
                    return; // nothing to do
                }

                lcd = LCDList[0] as IMyTextPanel; // grab the first lcd

                temp = lcd.GetPublicText();       // grab the text
                if (temp.Contains(title))
                {
                    temp.Remove(temp.IndexOf(title, 0), title.Length); // remove the title
                } // if title
                temp = title + log + temp;                             // update the log string

                lcd.WritePublicText(temp);                             // write to first panel

                for (i = 1; i < LCDList.Count; i++)
                {
                    lcd = LCDList[i] as IMyTextPanel; // grab the panel
                    lcd.WritePublicText(temp);        // write subsequent panel(s)
                } // lcd for

                log = ""; // reset log buffer
            } // Update method
Exemplo n.º 25
0
        void Main(string args)
        {
            Echo("Hellow World");

            IMyTextPanel LCD = GridTerminalSystem.GetBlockWithName("LCDW") as IMyTextPanel;

            if (IfFirstRun)
            {
                LCDTotalString = LCD.GetPublicText();

                LCDGIFStringArray = LCDTotalString.Split('*');
                IndexMax          = LCDGIFStringArray.Length;
                IfFirstRun        = false;
            }


            LCD.WritePublicText(LCDGIFStringArray[Index]);
            Index++;
            if (Index >= IndexMax)
            {
                Index = 0;
            }
            Echo(Index.ToString());
            Echo(IfFirstRun.ToString());
            return;
        }
Exemplo n.º 26
0
        public void displayText()
        {
            IMyTextPanel block = (IMyTextPanel)this.myProgram.GridTerminalSystem.GetBlockWithName("LCD - Hangar 1 - Outer Airlock");

            if (block == null)
            {
                throw new Exception("Can not find LCD block");
            }
            this.screen = new List <string>(block.CustomData.Split('\n'));


            this.writeSquare(this.hangarAirlockIconGreen, 10, 100);
            this.writeSquare(this.hangarIconRed, 20, 40);
            this.writeSquare(this.hangarIconWhite, 50, 40);
            this.writeSquare(this.hangarIconGreen, 80, 40);
            this.writeSquare(this.hangarIconGreen, 110, 40);

            string str = "";

            foreach (var txt in this.screen)
            {
                str += txt + "\n";
            }
            block.WritePublicText(str);
            block.ShowPublicTextOnScreen();
        }
        public void LcdPrint(string msg, string lcdName = "VarPanel")
        {
            IMyTextPanel lcd =
                GridTerminalSystem.GetBlockWithName(lcdName) as IMyTextPanel;

            lcd.WritePublicText(lcd.GetPublicText() + msg);
        }
Exemplo n.º 28
0
        //
        // http://steamcommunity.com/sharedfiles/filedetails/?id=360966557
        // https://forum.keenswh.com/threads/pb-scripting-guide-how-to-use-self-updating.7398267/
        //
        //----------------------------------------------------------------------------------------------------------------------
        //              Kopioitava koodi
        //----------------------------------------------------------------------------------------------------------------------



        void Main()
        {
            // ------------ Auto update ---------------

            Runtime.UpdateFrequency = UpdateFrequency.Update10;

            // ------------ Definitions ---------------

            IMyTextPanel naytto1 = GridTerminalSystem.GetBlockWithName("Infoscreen") as IMyTextPanel;

            IMyCargoContainer cargo1 = GridTerminalSystem.GetBlockWithName("Hitsi cargo 1") as IMyCargoContainer;



            // ------------ Logic ---------------



            // --- Cargo 1 usage ---
            float usedVolume1 = 0.0f;
            float maxVolume1  = 0.0f;

            usedVolume1 = (float)cargo1.GetInventory(0).CurrentVolume;
            maxVolume1 += (float)cargo1.GetInventory(0).MaxVolume;
            float pctUsed1 = 100.0f * usedVolume1 / maxVolume1;


            // ------------ Screen writing ---------------


            naytto1.WritePublicText("\n\n\n\n  Cargo-1 käytössä:  " + (int)pctUsed1 + "%", false);


            naytto1.ShowPublicTextOnScreen();
        }
Exemplo n.º 29
0
        /// <summary>
        /// Builds detectedGrids from a text panel.
        /// </summary>
        /// <param name="textPanelName">text panel name to lookup</param>
        void createListDetected(string textPanelName)
        {
            // get panel
            IMyTextPanel            panel      = null;
            List <IMyTerminalBlock> textPanels = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(textPanels);
            for (int index = 0; index < textPanels.Count; index++)
            {
                if (textPanels[index].DisplayNameText == textPanelName)
                {
                    panel = textPanels[index] as IMyTextPanel;
                    break;
                }
            }

            // assume panel has been filled, otherwise something went horribly wrong

            // get data
            string[] splitByLine = panel.GetPublicText().Split(newLine, StringSplitOptions.RemoveEmptyEntries);

            // erase panel
            panel.WritePublicText("");

            // build from data and invoke handler
            for (int lineIndex = 0; lineIndex < splitByLine.Length; lineIndex++)
            {
                if (!string.IsNullOrWhiteSpace(splitByLine[lineIndex]))
                {
                    //string distanceString = splitByLine[lineIndex].Split(separator)[4];
                    //debug("distance = "+distanceString+" => "+);
                    handle_detectedGrid(new Detected(splitByLine[lineIndex]));
                }
            }
        }
Exemplo n.º 30
0
        //------------------------------------------------------------------------
        // DrawText
        //------------------------------------------------------------------------

        private void DrawText(IMyTextPanel textPanel, String text, bool bNewLine = true)
        {
            Echo(text);

            if (textPanel != null)
            {
                if (bNewLine)
                {
                    textPanel.WritePublicText(text + Environment.NewLine, true);
                }
                else
                {
                    textPanel.WritePublicText(text, true);
                }
            }
        }
Exemplo n.º 31
0
    public static void Terminate()
    {
        // Generate title line
        String title_line, hb;

        if (heartbeat)
        {
            heartbeat = false;
            hb        = "\\";
        }
        else
        {
            heartbeat = true;
            hb        = "/";
        }
        if (is_sec_run)
        {
            title_line = String.Format("{0} #\n\n", term_title);
        }
        else
        {
            title_line = String.Format("{0} {1}\n\n", term_title, hb);
        }

        _term.WritePublicText(title_line + _stdout);
        _stdout = null;

        // Docking changes this object, so unset it to help garbage collection
        GridTerminalSystem = null;
    }