Guest User

SE Ship/Station AI Screen Module v1.0.3

a guest
Mar 4th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 25.45 KB | None | 0 0
  1. #region CodeEditor
  2.  
  3.  
  4.         /*
  5.          * ShipAI Screen module, written by Anthropy Februari 2015.  
  6.          * Requires ShipAI Core module to function. See Workshop page for more info.
  7.         */
  8.  
  9.         // ====CUSTOM SCREEN TEMPLATE SECTION=====
  10.         // For a list of available variables, see the Variables region below.  
  11.         // Anything listed there /should/ be available by just enclosing the variable name with accolades.
  12.         // e.g: '{wattHourBatteries}' will turn into something like '1MWh'. Note that values are formatted by default.
  13.         // For more info see the bottom of this section.
  14.  
  15.         //This is an example which shows a full block report that includes offline blocks some of you have asked for.
  16.         const string customScreenTemplate1 = "Custom screen module 1\nFull Block report:\n{damageReport}\n{offlineReport}";
  17.         //Note that \n is a newline
  18.          
  19.  
  20.  
  21.         // Note that you can create way more advanced screens by replacing "const string customScreenTemplateX = 'something'"  
  22.         // with "string customScreenTemplateX { get { return 'something'; } }".  
  23.         // This will allow you to use any code before it is formatted by the template engine.
  24.         // By using if(codeBlue) {} for example, you can only show certain parts in case of code Blue alerts.
  25.         //
  26.         // To create more custom screens, you have to do the following:
  27.         // 1) Create a new string customScreen__ where __ is your custom name.
  28.         // 2) Scroll down to region Variables and add a List<IMyTextPanel> customScreen__;
  29.         // 3) Scroll down to updateLCDPanels() and follow the instructions there
  30.         // 4) Scroll all the way down to just above Main(), copypaste the entire updateCustomScreen1 member, and replace the names accordingly
  31.         // 5) Scroll down to Main() and add your updateCustomScreen__() function to Main() so it gets executed.
  32.         // 6) Place LCD panels on your ship with names ending in _customscreen__
  33.         // 7) Make sure ownership is set, 'show text on screne' set to public, etc.
  34.         // 8) Enjoy!
  35.         // ====END CUSTOM SCREEN TEMPLATE SECTION====
  36.  
  37.         #region Variables
  38.         //Cached variables. Talking with ai_storage is expensive, so keep everything in memory when possible.
  39.         //All but the textpanel lists below are fetched from the ai_storage panel when updateCachedValues() is called.
  40.  
  41.         //Add extra customScreenX lists below here
  42.         List<IMyTextPanel> customScreens1 = new List<IMyTextPanel>();
  43.  
  44.         List<IMyTextPanel> updatePanels = new List<IMyTextPanel>();
  45.         List<IMyTextPanel> iconPanels = new List<IMyTextPanel>();
  46.         List<IMyTextPanel> battlePanels = new List<IMyTextPanel>();
  47.         IMyTextPanel debugPanel;
  48.         IMyTextPanel storagePanel;
  49.  
  50.         Dictionary<string, int> missingBlocks = new Dictionary<string, int>();
  51.  
  52.         public double wattHourInBatteries;
  53.         public double maxWattHourInBatteries ;
  54.  
  55.         public double solarpanelWatts ;
  56.         public double solarpanelMaxWatts;
  57.         public double reactorWatts ;
  58.         public double reactorMaxWatts;
  59.         public double batteryWatts ;
  60.         public double batteryMaxWatts;
  61.         public double batteryInputWatts ;
  62.         public double batteryInputMaxWatts;
  63.  
  64.         public double maxPower ;    
  65.         public double powerUsage ;
  66.          
  67.         public int reactorCount;
  68.         public int solarpanelCount;
  69.         public int batteryCount;
  70.         public int refineryCount;
  71.         public int assemblerCount;
  72.         public int antennaCount;
  73.         public int beaconCount;
  74.  
  75.         public int dischargingBatteries ;
  76.         public int brokenBlockCount;
  77.         public int offlineBlockCount;
  78.         public int activeAssemblers ;
  79.         public int activeRefineries;
  80.  
  81.         public bool tooManyBatteries ;
  82.         public bool tooManyReactors ;
  83.         public bool tooManySolarpanels ;
  84.         public bool tooManyAntennas ;
  85.         public bool tooManyBeacons ;
  86.  
  87.         public string shipName;
  88.  
  89.         /// <summary>
  90.         /// Returns the given string, with all {variable} names replaced with actual values.
  91.         /// Yes, this is a template parser,  
  92.         /// in an ingame script engine, in a game written in a 4th generation language. [Inception.wav]
  93.         /// </summary>
  94.         /// <param name="templateString"></param>
  95.         /// <returns></returns>
  96.         string formatScreenOutput(string templateString)
  97.         {
  98.             return templateString
  99.                 .Replace("{wattHourInBatteries}", getNormalizedPowerString(wattHourInBatteries, true))
  100.                 .Replace("{maxWattHourInBatteries}", getNormalizedPowerString(maxWattHourInBatteries, true))
  101.  
  102.                 .Replace("{solarpanelWatts}", getNormalizedPowerString(solarpanelWatts, false))
  103.                 .Replace("{solarpanelMaxWatts}", getNormalizedPowerString(solarpanelMaxWatts, false))
  104.                 .Replace("{reactorWatts}", getNormalizedPowerString(reactorWatts, false))
  105.                 .Replace("{reactorMaxWatts}", getNormalizedPowerString(reactorMaxWatts, false))
  106.                 .Replace("{batteryWatts}", getNormalizedPowerString(batteryWatts, false))
  107.                 .Replace("{batteryMaxWatts}", getNormalizedPowerString(batteryMaxWatts, false))
  108.                 .Replace("{batteryInputWatts}", getNormalizedPowerString(batteryInputWatts, false))
  109.                 .Replace("{batteryInputMaxWatts}", getNormalizedPowerString(batteryInputMaxWatts, false))
  110.  
  111.                 .Replace("{maxPower}", getNormalizedPowerString(maxPower, false))
  112.                 .Replace("{powerUsage}", getNormalizedPowerString(powerUsage, false))
  113.  
  114.                 .Replace("{reactorCount}", reactorCount.ToString())
  115.                 .Replace("{solarpanelCount}", solarpanelCount.ToString())
  116.                 .Replace("{batteryCount}", batteryCount.ToString())
  117.                 .Replace("{refineryCount}", refineryCount.ToString())
  118.                 .Replace("{assemblerCount}", assemblerCount.ToString())
  119.                 .Replace("{antennaCount}", antennaCount.ToString())
  120.                 .Replace("{beaconCount}", beaconCount.ToString())
  121.  
  122.  
  123.                 .Replace("{dischargingBatteries}", dischargingBatteries.ToString())
  124.                 .Replace("{brokenBlockCount}", brokenBlockCount.ToString())
  125.                 .Replace("{offlineBlockCount}", offlineBlockCount.ToString())
  126.                 .Replace("{activeAssemblers}", activeAssemblers.ToString())
  127.                 .Replace("{activeRefineries}", activeRefineries.ToString())
  128.  
  129.  
  130.                 .Replace("{tooManyBatteries}", tooManyBatteries.ToString())
  131.                 .Replace("{tooManyReactors}", tooManyReactors.ToString())
  132.                 .Replace("{tooManySolarpanels}", tooManySolarpanels.ToString())
  133.                 .Replace("{tooManyAntennas}", tooManyAntennas.ToString())
  134.                 .Replace("{tooManyBeacons}", tooManyBeacons.ToString())
  135.  
  136.                 .Replace("{shipName}", shipName)
  137.                 .Replace("{shortCommsStatus}", getVariable("shortCommsStatus"))
  138.  
  139.                 //Below are calls to methods and properties, which means they don't exist in the variable list on the top of the script.
  140.                 .Replace("{alertState}", getVariable("alertState"))
  141.                 .Replace("{powerState}", getVariable("powerState"))
  142.                 .Replace("{antennaString}", getVariable("antennaString"))
  143.                 .Replace("{beaconString}", getVariable("beaconString"))
  144.  
  145.                 .Replace("{damageReport}", getVariable("damageReport"))
  146.                 .Replace("{offlineReport}", getVariable("offlineReport"))
  147.                 .Replace("{missingReport}", getVariable("missingReport"))
  148.  
  149.  
  150.  
  151.                 ;
  152.         }
  153.  
  154.         #endregion
  155.  
  156.  
  157.  
  158.         public bool codeBlue
  159.         {
  160.             get { return getVariable("alertState").Equals("blue"); }
  161.             set
  162.             {
  163.                 if (value)
  164.                 {
  165.                     storeVariable("alertState", "blue");
  166.                 }
  167.                 else
  168.                 {
  169.                     storeVariable("alertState","none");
  170.                 }
  171.             }
  172.         }
  173.         public bool codeOrange
  174.         {
  175.             get { return getVariable("alertState").Equals("orange"); }
  176.             set
  177.             {
  178.                 if (value)
  179.                 {
  180.                     storeVariable("alertState","orange");
  181.                 }
  182.                 else
  183.                 {
  184.                     storeVariable("alertState","none");
  185.                 }
  186.             }
  187.         }
  188.         public bool codeRed
  189.         {
  190.             //the easter egg here has been removed due to potential issues with the screen module template engine.
  191.             get { return getVariable("alertState").Equals("red"); }
  192.             set
  193.             {
  194.                 if (value)
  195.                 {
  196.                     storeVariable("alertState", "red");
  197.                 }
  198.                 else
  199.                 {
  200.                     storeVariable("alertState", "none");
  201.                 }
  202.             }
  203.         }
  204.  
  205.         //String formatting functions are listed below, you can use these if you extend your const string to a string method.
  206.         //See the (to be created) pastebin wiki for more info.
  207.  
  208.         /// <summary>
  209.         /// Get normalized power string, in watts, kilowatts, megawatts, or gigawatts.
  210.         /// </summary>
  211.         /// <param name="watts">Raw value in watts</param>
  212.         /// <param name="hour">Whether or not to add an h to the end of the string</param>
  213.         /// <returns></returns>
  214.         public string getNormalizedPowerString(double watts, bool hour)
  215.         {
  216.             string h = "";
  217.             if (hour) { h = "h"; }
  218.             if (watts > 1000000000)
  219.             {
  220.                 return string.Format("{0}Gw{1}", watts / 1000000000, h);
  221.             }
  222.             else if (watts > 1000000)
  223.             {
  224.                 return string.Format("{0}Mw{1}", watts / 1000000, h);
  225.             }
  226.             else if (watts > 1000)
  227.             {
  228.                 return string.Format("{0}Kw{1}", watts / 1000, h);
  229.             }
  230.             else
  231.             {
  232.                 return string.Format("{0}w{1}", watts, h);
  233.             }
  234.         }
  235.  
  236.  
  237.         //Internal functions used for updating variables and what not.  
  238.         //Don't call them unless you know what you're doing.
  239.  
  240.         void updateLCDPanels()
  241.         {
  242.             debugPanel = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("debugpanel_gpu");
  243.             storagePanel = (IMyTextPanel)GridTerminalSystem.GetBlockWithName("ai_storage");
  244.             if (storagePanel == null)
  245.             {
  246.                 debugOutput("ERROR: NO STORAGE FOUND. Throwing exception..");
  247.                 debugOutput("Please create an LCD panel named 'ai_storage'.");
  248.                 debugOutput("Storage is required for proper functioning of the AI.");
  249.                 debugOutput("Without storage the Core won't even run.\nDid you install the screen module before the AI Core?");
  250.                 throw new Exception("No storage found!\nNote that this module does not work without the AI Core!\nPlease install the AI Core for more info.");
  251.             }
  252.             storeVariable("Red one standing by.", "screensModuleStatus"); //Let the AI Core know we're ready to rock
  253.             //Reset debugpanel
  254.             if (debugPanel != null) { debugPanel.WritePublicText(""); }
  255.  
  256.             debugOutput("Updating LCD Panels..");
  257.             List<IMyTerminalBlock> templist = new List<IMyTerminalBlock>();
  258.             GridTerminalSystem.GetBlocksOfType<IMyTextPanel>(templist);
  259.  
  260.             updatePanels.Clear();
  261.             iconPanels.Clear();
  262.  
  263.             //Add your customScreens__ list here, or it will eventually overflow.
  264.             customScreens1.Clear();
  265.              
  266.             for (int i = 0; i < templist.Count; i++)
  267.             {
  268.                     if (templist[i].DisplayNameText.EndsWith("_status"))
  269.                     {
  270.                         updatePanels.Add((IMyTextPanel)templist[i]);
  271.                     }
  272.                     else if (templist[i].DisplayNameText.EndsWith("_icons"))
  273.                     {
  274.                         iconPanels.Add((IMyTextPanel)templist[i]);
  275.                     }
  276.                     //Add extra customscreens here, or they won't be added to the list.
  277.                     //Simply copypaste the else if(){} below and replace 1 by your custom name.
  278.                     else if (templist[i].DisplayNameText.EndsWith("_customscreen1"))
  279.                     {
  280.                         customScreens1.Add((IMyTextPanel)templist[i]);
  281.                     }
  282.             }
  283.         }
  284.  
  285.         /// <summary>
  286.         /// Fetches last values from the ai_storage.  
  287.         /// Expensive call, don't use more than necessary.
  288.         /// Needed before any cached variables are initialized though,
  289.         /// make sure to call BEFORE using any or you'll get NullReferenceExceptions.
  290.         ///  
  291.         /// </summary>
  292.         void updateCachedValues()
  293.         {
  294.  
  295.             debugOutput("Updating cached values from ai_storage..");
  296.             if (getVariable("alertState") == null) //This variable should always be present.
  297.             {
  298.                 debugOutput("Error: value retrieval test failed.\nThrowing helpful error message instead of nullreference garbage.");
  299.                 throw new Exception("Unable to load required values from ai_storage.\nIs the AI core running correctly?");  
  300.             }
  301.             if (getVariable("wattHourInBatteries") == null) //This variable should always be present if the AI Core is saving Screens Module data correctly
  302.             {
  303.                 debugOutput("Error: still waiting for Core to update ai_storage with useful values..");
  304.                  
  305.  
  306.                 return;
  307.             }
  308.             //NOTE: Try{}catch(){} do not work! I left this here to remind me of the mistakes I made :'(  
  309.             try
  310.             {
  311.                 // The layout here should be exactly that of the Variables region,  
  312.                 // so you can confirm if there's anything missing in case of bugs.
  313.                 missingBlocks = deserializeDictionary(getVariable("missingBlocks"));
  314.  
  315.                 double.TryParse((getVariable("wattHourInBatteries")), out wattHourInBatteries);
  316.                 maxWattHourInBatteries = double.Parse(getVariable("maxWattHourInBatteries"));
  317.  
  318.                 solarpanelWatts = double.Parse(getVariable("solarpanelWatts"));
  319.                 solarpanelMaxWatts = double.Parse(getVariable("solarpanelMaxWatts"));
  320.                 reactorWatts = double.Parse(getVariable("reactorWatts"));
  321.                 reactorMaxWatts = double.Parse(getVariable("reactorMaxWatts"));
  322.                 batteryWatts = double.Parse(getVariable("batteryWatts"));
  323.                 batteryMaxWatts = double.Parse(getVariable("batteryMaxWatts"));
  324.                 batteryInputWatts = double.Parse(getVariable("batteryInputWatts"));
  325.                 batteryInputMaxWatts = double.Parse(getVariable("batteryInputMaxWatts"));
  326.  
  327.                 maxPower = double.Parse(getVariable("maxPower"));
  328.                 powerUsage = double.Parse(getVariable("powerUsage"));
  329.  
  330.                 reactorCount = int.Parse(getVariable("reactorCount"));
  331.                 solarpanelCount = int.Parse(getVariable("solarpanelCount"));
  332.                 batteryCount = int.Parse(getVariable("batteryCount"));
  333.                 refineryCount = int.Parse(getVariable("refineryCount"));
  334.                 assemblerCount = int.Parse(getVariable("assemblerCount"));
  335.                 antennaCount = int.Parse(getVariable("antennaCount"));
  336.                 beaconCount = int.Parse(getVariable("beaconCount"));
  337.  
  338.                 dischargingBatteries = int.Parse(getVariable("dischargingBatteries"));
  339.                 brokenBlockCount = int.Parse(getVariable("brokenBlockCount"));
  340.                 offlineBlockCount = int.Parse(getVariable("offlineBlockCount"));
  341.                 activeAssemblers = int.Parse(getVariable("activeAssemblers"));
  342.                 activeRefineries = int.Parse(getVariable("activeRefineries"));
  343.  
  344.  
  345.                 tooManyBatteries = bool.Parse(getVariable("tooManyBatteries"));
  346.                 tooManyReactors = bool.Parse(getVariable("tooManyReactors"));
  347.                 tooManySolarpanels = bool.Parse(getVariable("tooManySolarpanels"));
  348.                 tooManyAntennas = bool.Parse(getVariable("tooManyAntennas"));
  349.                 tooManyBeacons = bool.Parse(getVariable("tooManyBeacons"));
  350.  
  351.                 shipName = getVariable("shipName");
  352.                 //antennaString and beaconString are routed through a property due to newline conversion
  353.  
  354.                 storeVariable("Red one standing by.", "screenModuleStatus"); //Let the AI Core know we're ready to rock
  355.             }
  356.             catch (Exception)
  357.             {
  358.                 throw new Exception("Unable to load required values from ai_storage.\nIs the AI core running correctly?");
  359.             }
  360.             debugOutput("Done updating cached values.");
  361.         }
  362.  
  363.  
  364.  
  365.         /// <summary>
  366.         /// Prints a line to the debugpanel, if there is one (doesn't throw exceptions)
  367.         /// </summary>
  368.         /// <param name="output"></param>
  369.         void debugOutput(string output)
  370.         {
  371.             if (debugPanel != null)
  372.             {
  373.                 debugPanel.WritePublicText(output + "\n", true);
  374.                 if (debugPanel.GetPublicText().Length > 1000)
  375.                 {
  376.                     debugPanel.WritePublicText("WARNING: Debug log truncated due to size!\n");
  377.                 }
  378.             }
  379.              
  380.         }
  381.  
  382.  
  383.         public string serializeDictionary(Dictionary<string, int> dict)
  384.         {
  385.             string output = "";
  386.             string[] keys = new string[dict.Keys.Count];
  387.             int[] values = new int[dict.Values.Count];
  388.             dict.Keys.CopyTo(keys, 0);
  389.             dict.Values.CopyTo(values, 0);
  390.             for (int i = 0; i < dict.Count; i++)
  391.             {
  392.                 output += "\n" + keys[i] + ":" + values[i].ToString();
  393.             }
  394.             return output;
  395.         }
  396.  
  397.         public Dictionary<string, int> deserializeDictionary(string input)
  398.         {
  399.             Dictionary<string, int> returndict = new Dictionary<string, int>();
  400.             string[] inputLines = input.Split('\n');
  401.             for (int i = 0; i < inputLines.Length - 1; i++)
  402.             {
  403.                 if (inputLines[i].Length < 1) { continue; }
  404.                 string[] inputLineParts = inputLines[i].Split(':');
  405.                 if (inputLineParts.Length > 0)
  406.                 {
  407.                     returndict.Add(inputLineParts[0], int.Parse(inputLineParts[1]));
  408.                 }
  409.             }
  410.  
  411.             return returndict;
  412.         }
  413.  
  414.         //Stores a variable using a LCD panel named 'ai_storage'.  
  415.         //Colons and newlines can now be used, as I'm substituting them internally.
  416.         //Don't use [COLON] or [NEWLINE] though, they will be replaced by getVariable()
  417.         void storeVariable(string variable, string name)
  418.         {
  419.             variable = variable.Replace(":", "[COLON]").Replace("\n", "[NEWLINE]");
  420.             List<string> c = new List<string>();
  421.             string b = storagePanel.GetPublicText();
  422.             string oldvar;
  423.             if (b.Contains(name + ":"))
  424.             {
  425.                 oldvar = getVariable(name);
  426.                 b = b.Replace(name + ":" + oldvar, name + ":" + variable);
  427.             }
  428.             else
  429.             {
  430.                 b += "\n" + name + ":" + variable;
  431.             }
  432.  
  433.             storagePanel.WritePublicText(b);
  434.             //This call is too often used to always log. Turn on if needed.
  435.             //debugOutput(string.Format("storeVariable(): {0} '{1}'", name, variable));
  436.         }
  437.  
  438.         //Retrieves a variables from the ai_storage LCD panel.
  439.         string getVariable(string name)
  440.         {
  441.             List<string> b = new List<string>();
  442.             b.AddRange(storagePanel.GetPublicText().Split('\n'));
  443.             string toReturn = null;
  444.             for (int i = 0; i < b.Count; i++)
  445.             {
  446.                 if (b[i].StartsWith(name))
  447.                 {
  448.                     toReturn = b[i].Split(':')[1].Replace("[NEWLINE]", "\n").Replace("[COLON]", ":");
  449.                     break;
  450.                 }
  451.             }
  452.             if (toReturn == null)
  453.             {
  454.                 debugOutput(string.Format("No variable '{0}' found.", name));
  455.             }
  456.             else
  457.             {
  458.                 //This call is too heavy to always log on the Screen Module
  459.                // debugOutput(string.Format("getVariable(): {0} '{1}'", name, toReturn));
  460.             }
  461.  
  462.             return toReturn;
  463.         }
  464.  
  465.  
  466.         /// <summary>
  467.         /// Updates all LCD panels with _Status suffix with useful information and messages.
  468.         /// This is by far the heaviest function, but turning it off will also cripple the AI's functionality heavily.
  469.         /// </summary>
  470.         void updateStatusPanels(bool doDamageReport = true)
  471.         {
  472.            
  473.             //Format information for displaying
  474.             StringBuilder updateScreenBuilder = new StringBuilder();
  475.  
  476.             updateScreenBuilder.AppendFormat( //Status screen parts
  477.                 "{0} - {1}\nStatus: {2}{3}{4}\nActivated modules: Screen",
  478.                 shipName,
  479.                 DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToLongDateString(),
  480.                     getVariable("shortStatus"),
  481.                     getVariable("damageReport"),
  482.                     getVariable("StatusString")
  483.                 );
  484.             //Show Assembler information if there are assemblers
  485.             if (assemblerCount > 0)
  486.             {
  487.                 updateScreenBuilder.AppendFormat(
  488.                     "\nAssembly: {0}",
  489.                     string.Format(
  490.                     "{0} assemblers, {1} active.",
  491.                     new string[] {
  492.                         assemblerCount.ToString(),  
  493.                         activeAssemblers.ToString()  
  494.                         })
  495.                     );
  496.             }
  497.  
  498.             //Show Ore processing information if there are refineries
  499.             if (refineryCount > 0)
  500.             {
  501.                 updateScreenBuilder.AppendFormat(
  502.                     "\nOre processing: {0}",
  503.                     string.Format(
  504.                     "{0} refineries, {1} active.",
  505.                     new string[] {
  506.                         refineryCount.ToString(),  
  507.                         activeRefineries.ToString()  
  508.                         })
  509.                     );
  510.             }
  511.  
  512.             //Show power information  
  513.             updateScreenBuilder.AppendFormat("\nPower: {0}", getVariable("powerReport"));
  514.             //Show Comms information
  515.             updateScreenBuilder.AppendFormat(
  516.                 "\nComms: {0}{1}{2}",
  517.                 getVariable("shortCommsStatus"),
  518.                 getVariable("antennaString"),
  519.                 getVariable("beaconString")
  520.                 );
  521.  
  522.  
  523.  
  524.  
  525.             //Apply text to all screens with _status suffix
  526.             for (int i = 0; i < updatePanels.Count; i++)
  527.             {
  528.                 if (updatePanels[i].DisplayNameText.EndsWith("_status"))
  529.                 {
  530.                     IMyTextPanel screen = (IMyTextPanel)updatePanels[i];
  531.                     screen.WritePublicText(updateScreenBuilder.ToString());
  532.                 }
  533.             }
  534.  
  535.  
  536.         }
  537.  
  538.         void updateIconPanels()
  539.         {
  540.             for (int i = 0; i < iconPanels.Count; i++)
  541.             {
  542.                 if (codeBlue)
  543.                 {
  544.                     iconPanels[i].AddImageToSelection("Construction");
  545.                     //THIS IS BROKEN UNTIL WE CAN REMOVE IMAGES. For fuck sake Keen Dx
  546.                 }
  547.  
  548.  
  549.                 iconPanels[i].ShowTextureOnScreen();
  550.             }
  551.         }
  552.  
  553.         //Copypaste this entire void{} and rename both the name as well as the variables in the for() loop.
  554.         void updateCustomScreens1()
  555.         {
  556.             debugOutput(string.Format("Writing to {0} panels", customScreens1.Count));
  557.             for (int i = 0; i < customScreens1.Count; i++)
  558.             {
  559.                 customScreens1[i].WritePublicText(formatScreenOutput(customScreenTemplate1));
  560.             }
  561.         }
  562.  
  563.         void Main()
  564.         {
  565.             updateLCDPanels();
  566.             updateCachedValues();
  567.             if (getVariable("wattHourInBatteries") == null) //This variable should always be present if the AI Core is saving Screens Module data correctly
  568.             {
  569.                 return;
  570.             }
  571.             debugOutput("Updating status panels.");
  572.             updateStatusPanels(true);
  573.  
  574.             debugOutput("Updating custom screens..");
  575.              
  576.             //Add your updateCustomScreen__() below here. You're done!
  577.             updateCustomScreens1();
  578.                          
  579.             debugOutput("Iteration done.");
  580.         }
  581.  
  582.  
  583.         #endregion
Advertisement
Add Comment
Please, Sign In to add comment