コード例 #1
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();
                }
            }
        }
コード例 #2
0
        //Display text as a percentage bar and numeric text
        private void displayPercentOnScreen(IMyTextPanel scr, int per)
        {
            int x = 100;
            int y = 0;

            scr.WritePublicText("");                                                                   //clear
            scr.FontSize        = scr.BlockDefinition.SubtypeName.Contains("Wide") ? 2.713F : 1.3565F; //size of 2.713 for wide, half that for normal
            scr.FontColor       = getDisplayColor(per);
            scr.BackgroundColor = getBCGColor(per);
            //scr.WritePublicTitle("Battery Fraction:");
            scr.WritePublicText("Battery Fraction:");
            scr.WritePublicText("\n", true);
            scr.WritePublicText("[", true);
            for (int i = per; i > 0; i -= 2)
            {
                scr.WritePublicText("|", true);
                y += 2;
            }
            for (int i = x - y; i > 0; i -= 2)
            {
                scr.WritePublicText("'", true);
            }
            scr.WritePublicText("] (" + per + "%)\n", true);
            scr.ShowTextureOnScreen();
            scr.ShowPublicTextOnScreen();
        }
コード例 #3
0
 public void Reset()
 {
     Panel.WritePublicText("");
     Panel.ShowPublicTextOnScreen();
     FontSize    = Panel.GetValue <float>("FontSize");
     ScaledWidth = BaseWidth / FontSize;
 }
コード例 #4
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();
 }
コード例 #5
0
        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();
        }
コード例 #6
0
        public void UpdateLCD()
        {
            if (Panel != null)
            {
                var sb = new StringBuilder();

                sb.Append(currentItem.UpdateDesc() ?? currentItem.Description);
                for (int i = 0; i < currentItem.Items.Count; i++)
                {
                    if (i == selectedItemIndex)
                    {
                        sb.Append("[ " + currentItem.Items[i].Name + " ]" + '\n');
                    }
                    else
                    {
                        sb.Append("  " + currentItem.Items[i].Name + '\n');
                    }
                }
                string result = sb.ToString();
                //saves bandwidth and render time
                if (Panel.GetPublicText() == result)
                {
                    return;
                }
                Panel.WritePublicText(result);
                //Panel.ShowPrivateTextOnScreen();
                Panel.ShowPublicTextOnScreen();
            }
        }
コード例 #7
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();
        }
コード例 #8
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();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: Naosyth/FlightAssist
        private void GetBlocks()
        {
            string        blockGroupName = configReader.Get <string>("blockGroupName");
            IMyBlockGroup blockGroup     = GridTerminalSystem.GetBlockGroupWithName(blockGroupName);

            List <IMyShipController> controllers = new List <IMyShipController>();

            blockGroup.GetBlocksOfType <IMyShipController>(controllers);
            if (controllers.Count == 0)
            {
                throw new Exception("Error: " + blockGroupName + " does not contain a cockpit or remote control block.");
            }
            cockpit = controllers[0];

            List <IMyTextPanel> textPanels = new List <IMyTextPanel>();

            blockGroup.GetBlocksOfType <IMyTextPanel>(textPanels);
            if (textPanels.Count > 0)
            {
                textPanel          = textPanels[0];
                textPanel.Font     = "Monospace";
                textPanel.FontSize = 1.0f;
                textPanel.ShowPublicTextOnScreen();
            }

            blockGroup.GetBlocksOfType <IMyGyro>(gyros);
            if (gyros.Count == 0)
            {
                throw new Exception("Error: " + blockGroupName + " does not contain any gyroscopes.");
            }
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: VMSBigot/SEScripts
        private void InitDisplays()
        {
            _leftLCD   = GridTerminalSystem.GetBlockWithName(LEFT_LCD) as IMyTextPanel;
            _rightLCD  = GridTerminalSystem.GetBlockWithName(RIGHT_LCD) as IMyTextPanel;
            _middleLCD = GridTerminalSystem.GetBlockWithName(MIDDLE_LCD) as IMyTextPanel;

            _middleLCD.ShowPublicTextOnScreen();
            _leftLCD.ShowPublicTextOnScreen();
            _rightLCD.ShowPublicTextOnScreen();

            _leftLCD.BackgroundColor   = BACKGROUND_COLOR;
            _rightLCD.BackgroundColor  = BACKGROUND_COLOR;
            _middleLCD.BackgroundColor = BACKGROUND_COLOR;

            _leftLCD.FontColor   = FOREGROUND_COLOR;
            _rightLCD.FontColor  = FOREGROUND_COLOR;
            _middleLCD.FontColor = FOREGROUND_COLOR;

            _leftLCD.Font   = FONT_NAME;
            _rightLCD.Font  = FONT_NAME;
            _middleLCD.Font = FONT_NAME;

            _leftLCD.FontSize   = FONT_SIZE;
            _rightLCD.FontSize  = FONT_SIZE;
            _middleLCD.FontSize = FONT_SIZE;
        }
コード例 #11
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;
}         // программ
コード例 #12
0
 void InitDisplay(IMyTextPanel panel)
 {
     panel.ShowPublicTextOnScreen();
     panel.FontColor = this.foregroundColor;
     //panel.Font = FontName;
     panel.FontSize = FontSize;
     panel.WritePublicText(string.Empty);
 }
コード例 #13
0
 void SetPanelText(IMyTextPanel panel, string text)
 {
     if (panel != null)
     {
         panel.WritePublicText(text);
         panel.ShowTextureOnScreen();
         panel.ShowPublicTextOnScreen();
     }
 }
コード例 #14
0
 void SetupLCD(IMyTextPanel panel, Color color)
 {
     panel.ShowPublicTextOnScreen();
     panel.BackgroundColor = color;
     panel.FontColor       = color;
     panel.Font            = "DEBUG";
     panel.FontSize        = 1;
     panel.WritePublicText(string.Empty, false);
 }
コード例 #15
0
        } // 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()
コード例 #16
0
ファイル: LCD.cs プロジェクト: VMSBigot/SEScripts
 void SetupLCD(IMyTextPanel panel)
 {
     panel.ShowPublicTextOnScreen();
     panel.BackgroundColor = BACKGROUND_COLOR;
     panel.FontColor       = FOREGROUND_COLOR;
     panel.Font            = FONT_NAME;
     panel.FontSize        = FONT_SIZE;
     panel.WritePublicText(string.Empty, false);
 }
コード例 #17
0
 public void paint()
 {
     for (int i = 0; i < height; i++)
     {
         screenLines[i] = string.Join(null, screen, i * width, width) + "\n";
     }
     console.WritePublicText(string.Concat(screenLines));
     console.ShowTextureOnScreen();
     console.ShowPublicTextOnScreen();
 }
コード例 #18
0
 // Method for writting to LCD Panels
 void SetText(List <IMyTerminalBlock> blocks, string LCDText, Color color)
 {
     for (int i = 0; i < blocks.Count; i++)
     {
         IMyTextPanel panel = blocks[i] as IMyTextPanel;
         panel.WritePublicText(LCDText);
         panel.SetValue("FontColor", color);
         panel.ShowTextureOnScreen();
         panel.ShowPublicTextOnScreen();
     }
 }
コード例 #19
0
        public void WriteToPanels(string msg, List <IMyTerminalBlock> panels, bool append = true)
        {
            for (int i = 0; i < panels.Count; i++)
            {
                IMyTextPanel panel = (panels[i] as IMyTextPanel);

                //Append the text
                panel.WritePublicText(msg + "\n", append);
                panel.ShowPublicTextOnScreen();
            }
        }
コード例 #20
0
        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();
                }
            }
        }
コード例 #21
0
        // TODO: display n to m lines.
        public void UpdatePublic(bool show = true)
        {
            if (FontSize != _panel.GetValueFloat("FontSize"))
            {
                _panel.SetValueFloat("FontSize", FontSize);
            }
            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();
                }
            }
        }
コード例 #22
0
            public Screen(int w, int h, IMyTextPanel obj)
            {
                width        = w;
                height       = h;
                screenObject = obj;

                pixels = new StringBuilder();
                for (int i = 0; i < h; i++)
                {
                    pixels.Append(pixel_off, w);
                    pixels.Append('\n');
                }

                obj.ShowPublicTextOnScreen();
                obj.FontSize = 0.2f;
            }
コード例 #23
0
 public void c_log(string message)
 {
     if (logPanel == null)
     {
         return;
     }
     if (message == null)
     {
         logPanel.WritePublicText("");
     }
     else
     {
         logPanel.WritePublicText(message + "\n", true);
     }
     logPanel.ShowPublicTextOnScreen();
 }
コード例 #24
0
        public void DisplayResourceNumbers(IMyTextPanel textPanel)
        {
            foreach (KeyValuePair <string, double[]> resource in resources)
            {
                var    resourceDisplayName = resourceDisplayStrings[resource.Key][0];
                var    resourceValueSpacer = resourceDisplayStrings[resource.Key][1];
                var    oreDisplayString    = FormatNumber(resource.Value[0]);
                var    ingotDisplayString  = FormatNumber(resource.Value[1]);
                String text = resourceDisplayName + resourceValueSpacer
                              + oreDisplayString + new string(' ', (int)(30 - (oreDisplayString.Length * 1.8)))
                              + ingotDisplayString + "\n";
                textPanel.WritePublicText(text, true);
            }

            textPanel.ShowPublicTextOnScreen();
        }
コード例 #25
0
            //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();
            }
コード例 #26
0
        /// <summary>
        /// Fetch LCD block group and return true if there is one.
        /// </summary>
        /// <returns></returns>
        private bool Fecth_LCD_Block_Group()
        {
            List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock> ();

            //  Checking for block group
            if (GridTerminalSystem.GetBlockGroupWithName(LCD_BLOCK_GROUP_NAME) != null)
            {
                GridTerminalSystem.GetBlockGroupWithName(LCD_BLOCK_GROUP_NAME).GetBlocks(blocks);
            }

            //  If there is a block group and it's not empty
            if (blocks.Count > 0)
            {
                G_screens = new List <IMyTextPanel> ();

                //  Looping trough block group
                for (int element = 0; element < blocks.Count; element++)
                {
                    IMyTextPanel LCD = blocks [element] as IMyTextPanel;
                    LCD.ShowPublicTextOnScreen();   //  Setting screens to display text

                    //  If there is a master screen
                    if (LCD.CustomName.Contains(MASTER_LCD) && G_masterLCD == null)
                    {
                        LCD.CustomName = MASTER_LCD;    //  In case the master screen has a tag reset to default
                        G_masterLCD    = LCD;
                    }

                    //  If the screen still does not display text
                    if (LCD.ShowText != true)
                    {
                        debugText = ($"LCD with name ({LCD.CustomName}) could not be set to show public text on screen!\n");
                    }

                    LCD.FontColor = new Color(0, 255, 0); //  CHange font color of the screen to green
                    G_screens.Add(LCD);                   //  Add the screen to the G_Screens list
                }
                G_LCD = null;                             //  If there is a block group set single LCD to null
                return(true);
            }

            debugText = ($"(Optional) LCD group ({LCD_BLOCK_GROUP_NAME}) missing.\n");

            return(false);
        }
コード例 #27
0
        public void Main(string argument)
        {
            Echo("## START ##");
            IMyTextPanel LCD = GridTerminalSystem.GetBlockWithName(argument) as IMyTextPanel;

            if (LCD != null)
            {
                string[]               code   = LCD.CustomData.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                BMyBaconDraw           BD     = new BMyBaconDraw();
                BMyBaconDraw.BMyCanvas canvas = BD.run(code, this);
                LCD.WritePublicText(canvas.ToString());
                LCD.ShowPublicTextOnScreen();
            }
            else
            {
                Echo("-- LCD not found --");
            }
            Echo("## END ##");
        }
コード例 #28
0
            protected override void Enable()
            {
                if (textPanelBlock != null)
                {
                    normalShowText  = textPanelBlock.ShowText;
                    normalText      = textPanelBlock.GetPublicText();
                    normalFontSize  = textPanelBlock.FontSize;
                    normalFontColor = textPanelBlock.FontColor;
                    normalBgColor   = textPanelBlock.BackgroundColor;

                    textPanelBlock.WritePublicText(alertText);
                    textPanelBlock.FontSize        = fontSize;
                    textPanelBlock.FontColor       = fontColor;
                    textPanelBlock.BackgroundColor = bgColor;

                    textPanelBlock.Enabled = true;
                    textPanelBlock.ShowPublicTextOnScreen();
                }
            }
コード例 #29
0
        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();
            }
        }
コード例 #30
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  naytto     = GridTerminalSystem.GetBlockWithName("infoscreen") as IMyTextPanel;
            IMyPistonBase poraPiston = GridTerminalSystem.GetBlockWithName("Piston 1") as IMyPistonBase;
            IMyShipDrill  drill      = GridTerminalSystem.GetBlockWithName("Drill") as IMyShipDrill;

            float  sijainti    = 0.0f;
            float  velocity    = 0.0f;
            float  maxdepth    = 0.0f;
            string poratPaalla = null;

            // ------------ Logiikka ---------------

            if ((drill as IMyFunctionalBlock).Enabled == true)
            {
                poratPaalla = "Enabled";
            }
            else
            {
                poratPaalla = "Disabled";
            }



            sijainti = poraPiston.CurrentPosition;
            maxdepth = poraPiston.MaxLimit;
            velocity = poraPiston.Velocity;



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

            naytto.WritePublicText("Syvyys: " + sijainti.ToString("0.0") + "     Velocity: " + velocity.ToString("0.0") + "    Limit: " + maxdepth.ToString("0.0") + '\n', false);
            naytto.WritePublicText("Porat: " + poratPaalla, true);
            naytto.ShowPublicTextOnScreen();
        }
コード例 #31
0
        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
        }