Simple Jump Drive Charging Status Script NAN/5 (7)

posted in: Scripts | 12

The script below shows the charge status of your jump drives on an LCD panel.

Make sure to change the first line in the script to reflect the name of the LCD panel that you want to use to display the data. I use an LCD panel with the font size set to around 4 so it can be seen from a distance (my bridge is pretty big).

const String PANEL_NAME = "Jump Drive Panel"; 
const String MULTIPLIERS = ".kMGTPEZY" ; 
const int PANEL_LINES = 22; 
int lineOffset = 0; 
void Main() 
    List<IMyTerminalBlock> work = new List<IMyTerminalBlock>(); 
    List<IMyTerminalBlock> jumpdrives = new List<IMyTerminalBlock>(); 
    GridTerminalSystem.SearchBlocksOfName(PANEL_NAME, work); 
    IMyTextPanel panel = null; 
    for (int i = 0; i < work.Count; i++) 
        if (work[i] is IMyTextPanel) { 
            panel = (IMyTextPanel)work[i]; 
    System.Text.RegularExpressions.Regex batteryRegex = new System.Text.RegularExpressions.Regex( 
        "Max Stored Power: (\\d+\\.?\\d*) (\\w?)Wh", 
    System.Text.RegularExpressions.Regex batteryRegex2 = new System.Text.RegularExpressions.Regex( 
        "Stored power: (\\d+\\.?\\d*) (\\w?)Wh", 

    List<String> list = new List<String>(); 
    double maxStoredPower = 0.0f; 
    double currentStoredPower = 0.0f; 
    for (int i = 0; i < jumpdrives.Count; i++) 
        System.Text.RegularExpressions.Match match = batteryRegex.Match(jumpdrives[i].DetailedInfo); 
        double parsedDouble = 0.0f; 
        if (match.Success) { 
            if (Double.TryParse(match.Groups[1].Value, out parsedDouble)) { 
                maxStoredPower += parsedDouble * Math.Pow(1000.0, MULTIPLIERS.IndexOf(match.Groups[2].Value)); 

        match = batteryRegex2.Match(jumpdrives[i].DetailedInfo); 
        if (match.Success) { 
            if (Double.TryParse(match.Groups[1].Value, out parsedDouble)) { 
                currentStoredPower += parsedDouble * Math.Pow(1000.0, MULTIPLIERS.IndexOf(match.Groups[2].Value)); 

    list.Add(" "+percentFormatter(currentStoredPower/maxStoredPower*100)); 
    list.Insert(0,"Jump Drive\n"); 
    for (int o=0; o < lineOffset; o++) { 
        String shiftedItem = list[0]; 

    panel.WritePublicText(String.Join("\n",list.ToArray()), false); 

    if (list.Count > PANEL_LINES) { 
        if (list.Count - lineOffset < PANEL_LINES) { 
            lineOffset = 0; 
String percentFormatter(double percent) { 
    return "" + Math.Round((double)percent,2).ToString("##0.00") + " %"; 

Please rate this post

12 Responses

  1. I think you might’ve accidentally forgot the opening tag 🙂

  2. Actually, I didn’t forget the tag, but something about the formatting of the code was throwing it off.

    Thanks for the heads-up, good sir!

  3. Hey. I don’t know if the text is messing up on lines 9 and 10 but I keep getting errors when I compile the code. You seen like you know what your doing (in a nooby at c# so I only understand some of what the code is doing) so my only explanation is that the HTML coding is jacking up what you tried to type out. I’d really like to use this script so I’d appreciate any help you have give.

    Thank you.

  4. OK no problem. For example. Line 9. When I compile. I get this error code back ‘Using the generic type System.Collections.Generic.List requires 1 type arguments’.

    Line 9 reads List work = new List();
    for me.

  5. And I think I found my answer. The html
    Script is hiding the information in the less than greater than brackets. I tried to type a less than with a T between it and a greater than sign. It didn’t show on the message I just sent you.

    And sorry I’m taking so long to type. I’m on a cell phone.

  6. Ah sorry. Forgive me. Remember I’m a noob at this. Angle brackets. The angle brackets aren’t showing up I don’t think. Like if I type *angle bracket*Hello*angle bracket* it won’t show when I type it to you.

  7. Yeah… something about this script specifically is throwing off the parser that does the code highlighting.

    I fixed it now… without highlighting…

  8. Dude. You are awesome. And the fact you replied so quickly. Thank you. Got me excited to back into the game and try this out.
    Thanks man.

  9. Awesome stuff man. Works real nice. I just set it up with two rubber blocks that loop reach other and the screen auto updates itself without having to manually run the program each time I want to update where the % is at.

  10. Lol rubber blocks…. Lol… Ah man… Gotta love swipe to text…. Timer* blocks.

Leave a Reply