Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Main(string argument) {
- string ScreenName = "HUD1";
- string Spacing1 = " ";
- string Spacing2 = " ";
- int BarLength = 35;
- string BarFill = "|";
- string BarEmpty = ".";
- string Bar = "[";
- var allCargo = new List<IMyTerminalBlock>();
- GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(allCargo, b => b.CubeGrid == Me.CubeGrid);
- var PilotScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(ScreenName);
- double percentFull;
- float usedVolume = 0.0f;
- float maxVolume = 0.0f;
- allCargo.ForEach (cargo =>
- {
- usedVolume += (float)cargo.GetInventory(0).CurrentVolume;
- maxVolume += (float)cargo.GetInventory(0).MaxVolume;
- });
- float percentUsed = usedVolume / maxVolume;
- int FilledBar = (int)(BarLength * percentUsed);
- percentFull = Math.Round(100 * (usedVolume / maxVolume),2);
- for (int i = FilledBar; i > 0; i--) {
- Bar += BarFill;
- }
- for (int i = BarLength - FilledBar; i > 0; i--) {
- Bar += BarEmpty;
- }
- string TextOutput = Spacing1 + Bar + "]" + "\n" + Spacing2 + "Cargo Load: " + percentFull + "%";
- Echo (Spacing1 + Bar + "]" + "\n" + Spacing2 + "Cargo Load: " + percentFull + "%");
- //Echo("\n Grid Size: " + Me.CubeGrid.GridSizeEnum.ToString());
- if (PilotScreen == null)
- {
- Echo ("\n No LCD with name: " + ScreenName);
- return;
- }
- else
- {
- PilotScreen.WritePublicText(TextOutput);
- PilotScreen.ShowPublicTextOnScreen();
- if (Me.CubeGrid.GridSizeEnum.ToString() == "Large")
- {
- PilotScreen.SetValue("FontSize", 1f);
- }
- if (Me.CubeGrid.GridSizeEnum.ToString() == "Small")
- {
- PilotScreen.SetValue("FontSize", 1.5f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment