Closed tdierickx closed 2 years ago
You asked this a few months ago, so I'm not sure if you're still interested. To accomplish the first you need four pieces of information.
From there, it's simple calculations. Here's how I did it:
{{set 'PowCap' 4500}}
{{set 'BatCap' (calc @Root.Data.PowCap '-' @Root.E.S.FuelCapacity)}}
{{set 'BatCon' (calc @Root.E.S.Fuel '-' @Root.E.S.FuelTank.Content)}}
And if you want to make it look all nifty like the other bars you can do something like the following. It's not exactly like the original bars, but it looks better in my opinion.
{{set 'PowCap' 4500}}{{set 'BatCap' (calc @root.Data.PowCap '-' @root.E.S.FuelCapacity)}}{{set 'BatCon' (calc @Root.E.S.Fuel '-' @Root.E.S.FuelTank.Content)}}-- Battery {{math @Root.Data.BatCon '/' @Root.Data.BatCap}}{{~format . '{0:P2}'}}{{/math}} ({{calc @Root.Data.BatCon '*' 1.0 2}}/{{calc @Root.Data.Cap '*' 1.0 2}})</color>
<color=green>{{bar @Root.Data.BatCon 0 @Root.Data.BatCap 30}}</color>
For my bases I use this (it's still a work in progress, I haven't had the motivation to fix the decimal places - simple fix if you want to do it) to show Battery, O2 and Fuel:
{{set 'PowCap' 4500}}{{set 'BatCap' (calc @root.Data.PowCap '-' @root.E.S.FuelCapacity)}}{{set 'BatCon' (calc @Root.E.S.Fuel '-' @Root.E.S.FuelTank.Content)}}-- Battery {{math @Root.Data.BatCon '/' @Root.Data.BatCap}}{{~format . '{0:P2}'}}{{/math}} ({{calc @Root.Data.BatCon '*' 1.0 2}}/{{calc @Root.Data.Cap '*' 1.0 2}})</color>
<color=green>{{bar @Root.Data.BatCon 0 @Root.Data.BatCap 30}}</color>
{{#use E.S.OxygenTank}}
-- O2 {{ ~math Content '/' Capacity}}{{~format . '{0,8:P2}'}} ({{~/math}}{{~format Content '{0:0.0}'}}/{{format Capacity '{0:0.0}'}})
<color=white>{{bar Content 0 Capacity 30}}</color>{{/use}}
{{#use E.S.FuelTank}}
-- Fuel {{~math Content '/' Capacity}}{{~format . '{0,8:P2}'}}{{~/math}} ({{~format Content '{0:0.0}'}} / {{format Capacity '{0:0.0}'}})
<color=blue>{{bar Content 0 Capacity 30}}</color>{{/use}}
It's 835 / 2000 characters, so feel free to add more to it if you like. The only issue I'm aware of is that the last block of the bar is not filled when the batteries are 100% and I'm not sure why.
To get the remaining battery time, I'm not sure that's possible reliably. You'd have to store the previous value and compare it to the current values at a known interval (ie: 1 sec) to see how fast the batteries are draining, and calculate that against how much capacity they have. The problem, I think, is going to be in the daytime when the batteries should be charging. I think it'll give weird numbers. You can probably mitigate that by checking if the previous value was lower than the current value and putting questionmarks or something.
Your soulution is good, but the API gave me not information/data about the battery. So you have to caclulate it by yourself as you done it above.
I love this mod so far and really like what I've been able to with it so far, but now I'm wondering how to pull this battery info and display it on my "Power Stats" LCD I have started creating:
Thanks!