Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is simplified version of this script
- // http://steamcommunity.com/sharedfiles/filedetails/?id=902088441
- List<IMyTerminalBlock> ShieldsArray;
- List<IMyTerminalBlock> LCDsArray;
- public void SEStatusInit()
- {
- // Search for Shileds in Grid
- ShieldsArray = new List<IMyTerminalBlock>();
- GridTerminalSystem.SearchBlocksOfName("Shield Generator", ShieldsArray);
- // Building list of Displays to show status
- LCDsArray = new List<IMyTerminalBlock>();
- GridTerminalSystem.SearchBlocksOfName("[ShieldM]", LCDsArray);
- }
- public Program()
- {
- // Setting script for self-update eache 100 ticks = 1.6 sec
- Runtime.UpdateFrequency = UpdateFrequency.Update100;
- // Call init on 1st run!
- SEStatusInit();
- }
- public void Main(string argument)
- {
- // Loop through all lcds with designated name
- for (int i = 0; i < LCDsArray.Count; i++)
- {
- if (LCDsArray[i] == null)
- {
- Echo("You lost some lcds. ReCompile this script!");
- return;
- }
- IMyTextPanel LCD = (IMyTextPanel)LCDsArray[i];
- LCD.WritePublicText("", false);
- string ShieldsData = "";
- string OverallShield = "";
- string CurrentShield = "";
- string ShieldUnits = "";
- // Let's read date from shields, if we have them
- for (int j = 0; j < ShieldsArray.Count; j++)
- {
- if (ShieldsArray[j] == null)
- {
- Echo("You lost some shields. ReCompile this script!");
- LCD.WritePublicText("You lost some shields. ReCompile this script!", false);
- return;
- }
- ShieldsData = ShieldsArray[j].CustomInfo.Split('\n')[1];
- CurrentShield = ShieldsData.Split(' ')[2];
- OverallShield = ShieldsData.Split(' ')[3].Split('/')[1];
- ShieldUnits = ShieldsData.Split(' ')[3].Split('/')[0];
- }
- // Okay, shield data preserved.
- // Let's adjust lcd's and post data to them
- if (ShieldsArray.Count > 0)
- {
- LCD.SetValueFloat("FontSize", 1.4f);
- LCD.WritePublicText("Overall: " + CurrentShield + " of " + OverallShield + " " + ShieldUnits + "\n");
- float Cur = Convert.ToSingle(CurrentShield);
- float Max = Convert.ToSingle(OverallShield);
- float prog = (Cur / Max) * 67;
- float empt = (67 - prog) / 2;
- // This is where we went through lcds, and showing formated data
- for (int k = 0; k < prog; k++)
- {
- LCD.WritePublicText(LCD.GetPublicText() + "|");
- }
- }
- else
- {
- // This obviously will be shown if something wrong happend
- LCD.WritePublicText("You don't have Energy Shields\nor named them incorrectly.\n-------------------------------------------\n");
- LCD.WritePublicText(LCD.GetPublicText() + "Please, make shure you have \nmod installed, and shield \nblocks have 'Energy Shield'\n");
- LCD.WritePublicText(LCD.GetPublicText() + "phrase in blocks's name");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement