It is currently March 29th, 2024, 2:13 pm

How to show my battery life with Terraria Hearts

Get help with creating, editing & fixing problems with skins
David3214
Posts: 14
Joined: December 5th, 2017, 12:16 am

How to show my battery life with Terraria Hearts

Post by David3214 »

I'm completely new to Rainmeter and I'm trying to create a Terraria skin. Right now I am stuck on how to show the battery life with the terraria hearts. Any help with my code would be appreciated (Most of my questions are psuedo-coded in).

My Code:

;Most of this code was copied from Vit-Ok's battery skin, and me trying to modify it.

Code: Select all

[MeasurePercent]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=Percent
UpdateDivider=5

[MeasureLife]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=Lifetime
UpdateDivider=5

[BG]
Meter=Image
ImageName=bgM.png
Path="#MPath#\" 


[RH1]
Meter=Image
MeterStyle=Style
ImageName=#@#images\RH.png
MeasureName=MeasurePercent
X=0
Y=0


[RH2]
Meter=Image
MeterStyle=Style
ImageName=#@#images\RH.png
MeasureName=MeasurePercent
X=10
Y=0
;I'll keep doing RH for each heart in a full bar in terraria, and also gold hearts
;I'm also wanting to use faded hearts that I have for when the percent goes lower
;than a certain value for each one.
;And also use the golden hearts for when the computer is charging, with faded gold as well.
;I feel like there is a more efficient, and simpler way of doing this,
;but I'm new to Rainmeter and have almost no experience in making skins.

Code: Select all

[AC]
Measure=Plugin
Plugin=PowerPlugin.dll
PowerState=Status   
IfConditione= ;I want to be able to test the battery percent, and every 5% less fade another heart
IfTrueAction=!Execute [!RainmeterHideMeter][!RainmeterRedraw]
;I would then go through hiding all hearts not needed, instead showing their faded counterparts.
;This is the main part I have no idea what to do.
Last edited by fonpaolo on December 5th, 2017, 11:00 am, edited 1 time in total.
Reason: Please use the [Code] tags to display your code.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to show my battery life with Terraria Hearts

Post by balala »

David3214 wrote:;I'll keep doing RH for each heart in a full bar in terraria, and also gold hearts
;I'm also wanting to use faded hearts that I have for when the percent goes lower
;than a certain value for each one.
;And also use the golden hearts for when the computer is charging, with faded gold as well.
;I feel like there is a more efficient, and simpler way of doing this,
;but I'm new to Rainmeter and have almost no experience in making skins.
And there you have 21 Image meters (from [RH1], up to [RH21])? I suppose the appropriate number of them should be shown. Am I right?
If so, what you mean by "faded hearts"?
Although this solution doesn't use a fade effect to show / hide the meters (if this is what you want to use), here is a simple workaround: add the following options to the [MeasurePercent] measure:

Code: Select all

[MeasurePercent]
...
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!ShowMeter "RH1"][!HideMeter "RH2"][!HideMeter "RH3"][!HideMeter "RH4"][!HideMeter "RH5"][!HideMeter "RH6"][!HideMeter "RH7"][!HideMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition2=((#CURRENTSECTION#>0)&&(#CURRENTSECTION#<=5))
IfTrueAction2=[!ShowMeter "RH1"][!ShowMeter "RH2"][!HideMeter "RH3"][!HideMeter "RH4"][!HideMeter "RH5"][!HideMeter "RH6"][!HideMeter "RH7"][!HideMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition3=((#CURRENTSECTION#>5)&&(#CURRENTSECTION#<=10))
IfTrueAction3=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!HideMeter "RH4"][!HideMeter "RH5"][!HideMeter "RH6"][!HideMeter "RH7"][!HideMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition4=((#CURRENTSECTION#>10)&&(#CURRENTSECTION#<=15))
IfTrueAction4=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!HideMeter "RH5"][!HideMeter "RH6"][!HideMeter "RH7"][!HideMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition5=((#CURRENTSECTION#>15)&&(#CURRENTSECTION#<=20))
IfTrueAction5=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!HideMeter "RH6"][!HideMeter "RH7"][!HideMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition6=((#CURRENTSECTION#>20)&&(#CURRENTSECTION#<=25))
IfTrueAction6=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!HideMeter "RH7"][!HideMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition7=((#CURRENTSECTION#>25)&&(#CURRENTSECTION#<=30))
IfTrueAction7=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!HideMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition8=((#CURRENTSECTION#>30)&&(#CURRENTSECTION#<=35))
IfTrueAction8=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!HideMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition9=((#CURRENTSECTION#>35)&&(#CURRENTSECTION#<=40))
IfTrueAction9=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!HideMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition10=((#CURRENTSECTION#>40)&&(#CURRENTSECTION#<=45))
IfTrueAction10=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!HideMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition11=((#CURRENTSECTION#>45)&&(#CURRENTSECTION#<=50))
IfTrueAction11=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!HideMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition12=((#CURRENTSECTION#>50)&&(#CURRENTSECTION#<=55))
IfTrueAction12=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!HideMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition13=((#CURRENTSECTION#>55)&&(#CURRENTSECTION#<=60))
IfTrueAction13=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!HideMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition14=((#CURRENTSECTION#>60)&&(#CURRENTSECTION#<=65))
IfTrueAction14=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!HideMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition15=((#CURRENTSECTION#>65)&&(#CURRENTSECTION#<=70))
IfTrueAction15=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!ShowMeter "RH15"][!HideMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition16=((#CURRENTSECTION#>70)&&(#CURRENTSECTION#<=75))
IfTrueAction16=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!ShowMeter "RH15"][!ShowMeter "RH16"][!HideMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition17=((#CURRENTSECTION#>75)&&(#CURRENTSECTION#<=80))
IfTrueAction17=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!ShowMeter "RH15"][!ShowMeter "RH16"][!ShowMeter "RH17"][!HideMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition18=((#CURRENTSECTION#>80)&&(#CURRENTSECTION#<=85))
IfTrueAction18=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!ShowMeter "RH15"][!ShowMeter "RH16"][!ShowMeter "RH17"][!ShowMeter "RH18"][!HideMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition19=((#CURRENTSECTION#>85)&&(#CURRENTSECTION#<=90))
IfTrueAction19=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!ShowMeter "RH15"][!ShowMeter "RH16"][!ShowMeter "RH17"][!ShowMeter "RH18"][!ShowMeter "RH19"][!HideMeter "RH20"][!HideMeter "RH21"]
IfCondition20=((#CURRENTSECTION#>90)&&(#CURRENTSECTION#<=95))
IfTrueAction20=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!ShowMeter "RH15"][!ShowMeter "RH16"][!ShowMeter "RH17"][!ShowMeter "RH18"][!ShowMeter "RH19"][!ShowMeter "RH20"][!HideMeter "RH21"]
IfCondition21=(#CURRENTSECTION#>95)
IfTrueAction21=[!ShowMeter "RH1"][!ShowMeter "RH2"][!ShowMeter "RH3"][!ShowMeter "RH4"][!ShowMeter "RH5"][!ShowMeter "RH6"][!ShowMeter "RH7"][!ShowMeter "RH8"][!ShowMeter "RH9"][!ShowMeter "RH10"][!ShowMeter "RH11"][!ShowMeter "RH12"][!ShowMeter "RH13"][!ShowMeter "RH14"][!ShowMeter "RH15"][!ShowMeter "RH16"][!ShowMeter "RH17"][!ShowMeter "RH18"][!ShowMeter "RH19"][!ShowMeter "RH20"][!ShowMeter "RH21"]
I hope I didn't mess up something in these long options. Check them, to see if they are working well and please let me know if they are not.

Tip: you've used the following Plugin options on the appropriate plugin measures: PlugIn=[color=#FF0000]PlugIns\[/color]PowerPlugin[color=#FF0000].dll[/color]. The following shorter form of it can be used however: Plugin=PowerPlugin, which is completely enough.
David3214
Posts: 14
Joined: December 5th, 2017, 12:16 am

Re: How to show my battery life with Terraria Hearts

Post by David3214 »

Thank you for your response Balala, you did solve one of my issues. Could you maybe describe how you can evaluate the value of #CURRENTSECTION# and get the percent? As I said previously I am new to Rainmeter, though have spent some time working in C#, C++, and Python.
balala wrote:And there you have 21 Image meters (from [RH1], up to [RH21])? I suppose the appropriate number of them should be shown. Am I right?
If so, what you mean by "faded hearts"?
Although this solution doesn't use a fade effect to show / hide the meters (if this is what you want to use)
In terms of faded hearts, I meant in terraria when you lose hearts they still show up but faded and smaller. I have a separate image for this, because I thought it would be simpler than trying to transform the image with Rainmeter. I understand that I could do a show/hide for each of these as well, and may do that until I find a more condensed way.

One thing I wonder is there a more condensed way to do this, instead of writing out 20+ show/Hide statemets, and creating 20+ meters. Are there arrays or such in Rainmeter that you could store these in at all?

My last big question/Issue is how can I also test for whether the computer is plugged in? Currently all the hearts of Gold, but I want to be able to change all of the hearts to a golden color (a separate image) if it is plugged in. Could you describe how I could do this. Assume that the Meter's for the golden hearts are named [GH1]-[GH20].
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to show my battery life with Terraria Hearts

Post by balala »

David3214 wrote:Thank you for your response Balala, you did solve one of my issues. Could you maybe describe how you can evaluate the value of #CURRENTSECTION# and get the percent?
#CURRENTSECTION# is a built-in variable and represents the name of the meter / measure where is used. Because in the posted code I used that variable into the [MeasurePercent] measure, there #CURRENTSECTION# is MeasurePercent. So for example in the first Ifcondition option instead of IfCondition=(#CURRENTSECTION#=0) we have there IfCondition=(MeasurePercent=0). The measure returns the appropriate percent and the IfCondition options compare the returned percent with the numeric values set in those options.
David3214 wrote:As I said previously I am new to Rainmeter, though have spent some time working in C#, C++, and Python.
The best would be to forget your programming knowledge, regardless what are those (C#, C++, Python or anything else). At least while you're working with Rainmeter. Rainmeter is not a programming language: https://forum.rainmeter.net/viewtopic.php?p=136142#p136142
David3214 wrote:In terms of faded hearts, I meant in terraria when you lose hearts they still show up but faded and smaller. I have a separate image for this, because I thought it would be simpler than trying to transform the image with Rainmeter. I understand that I could do a show/hide for each of these as well, and may do that until I find a more condensed way.
In this case you should have to create another 21 "faded" meters, naming them for example as [FadeRH1] - [FadeRH21]. these meters obviously should contain the appropriate faded images.
Then you have to add in the posted IftrueAction options after each [!ShowMeter "RHXX"] and [!HideMeter "RHYY"] bangs, another one bang, to show the appropriate faded image, if the normal one is hidden and hide it, if the normal image is shown (accordingly [!HideMeter "FadeRHXX"] respectively [!ShowMeter "FadeRHYY"]). Eg the first two bangs of the IfTrueAction option should be replaced by IfTrueAction=[!ShowMeter "RH1"][!HideMeter "FadeRH1"][!HideMeter "RH2"][!ShowMeter "FadeRH2"]. This way every time when a meter is shown its appropriate faded meter is hidden and vice-versa: when a meter is hidden, its faded version is shown.
But the same well you could create just one set of image meters (the existing [RH1] - [RH21] meters), without the ImageName options, then set the name of image accordingly, depending on which image should be shown by that meter. Remaining on the previous example, instead of the IfTrueAction=[!ShowMeter "RH1"][!HideMeter "FadeRH1"][!HideMeter "RH2"][!ShowMeter "FadeRH2"] bangs, you should use this: IfTrueAction=[!SetOption RH1 ImageName "#@#images\RH.png"][!SetOption HideMeter RH2 "#@#images\FadeRH.png"].This way each of those !SetOption bangs will set the appropriate image for the appropriate image meter, depending on the percentage returned by the [MeasurePercent] measure.
David3214 wrote:One thing I wonder is there a more condensed way to do this, instead of writing out 20+ show/Hide statemets, and creating 20+ meters. Are there arrays or such in Rainmeter that you could store these in at all?
Not really in Rainmeter, because as I said above, it isn't a procedural programming language. Sorry...
David3214 wrote:My last big question/Issue is how can I also test for whether the computer is plugged in? Currently all the hearts of Gold, but I want to be able to change all of the hearts to a golden color (a separate image) if it is plugged in. Could you describe how I could do this. Assume that the Meter's for the golden hearts are named [GH1]-[GH20].
If you want to do this, first I'd recommend to stay on the !ShowMeter / !HideMeter solution and don't use the !SetOption solution, described above.
The following plugin measure returns 0 when the computer works on battery and 1 if it's plugged in:

Code: Select all

[MeasureAC]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=ACLINE
A set of IfCondition options could be used to set the appropriate image in both cases:

Code: Select all

[MeasureAC]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=ACLINE
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetOption RH1 ImageName "#@#images\RH-FOR-BATTERY.png"][!SetOption FadeRH1 ImageName "#@#images\FADE-RH-FOR-BATTERY.png"]...
IfFalseAction=[!SetOption RH1 ImageName "#@#images\RH-FOR-PLUGGED-IN.png"][!SetOption FadeRH1 ImageName "#@#images\FADE-RH-FOR-PLUGGED-IN.png"]...
Obviously you have to set on both options the images for all the RHXX meters. Also keep in mind this solution works only if you're using the previously described first solution, where we had two sets of meters, with different images. The second solution, which sets the appropriate image depending on the percentage, won't work in this case.

I hope these explanations was clear enough and you've understood. Please let me know if something isn't clear enough.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How to show my battery life with Terraria Hearts

Post by eclectic-tech »

There is no way in Rainmeter to use arrays for this (it is possible if you want to add a Lua script), but not necessary to achieve what you are trying to do.

Here is a slightly different approach to your skin that sets a variable to control the heart color based on [MeasureStatus] of the PowerState of the PowerPlugin. The value will be 1 if the battery is charging.

This will show 19 hearts, either red or gold depending on charge status and faded based on charge percentage. Because I didn't have a battery system, I used CPU and Random numbers to test (that is why you will see commented out lines) in [MeasurePercent] and [MeasureStatus].

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
Group=#RootConfig#

; ========= Metadata ==========
[Metadata]
Name=
Author=
Information=
License=Creative Commons Share-Alike NC 4
Version=

; ========= Variables ==========
[Variables]
; rh or gh for Red or Gold hearts
ImageColor=rh


; ========= Measures ==========

[MeasurePercent]
; Measure=CPU
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=Percent
UpdateDivider=5
IfCondition=(#CurrentSection#>5)
IfTrueAction=[!SetOption RH1 ImageName "#*ImageColor*#1"]
IfFalseAction=[!SetOption RH1 ImageName "#*ImageColor*#0"]
IfCondition2=(#CurrentSection#>10)
IfTrueAction2=[!SetOption RH2 ImageName "#*ImageColor*#1"]
IfFalseAction2=[!SetOption RH2 ImageName "#*ImageColor*#0"]
IfCondition3=(#CurrentSection#>15)
IfTrueAction3=[!SetOption RH3 ImageName "#*ImageColor*#1"]
IfFalseAction3=[!SetOption RH3 ImageName "#*ImageColor*#0"]
IfCondition4=(#CurrentSection#>20)
IfTrueAction4=[!SetOption RH4 ImageName "#*ImageColor*#1"]
IfFalseAction4=[!SetOption RH4 ImageName "#*ImageColor*#0"]
IfCondition5=(#CurrentSection#>25)
IfTrueAction5=[!SetOption RH5 ImageName "#*ImageColor*#1"]
IfFalseAction5=[!SetOption RH5 ImageName "#*ImageColor*#0"]
IfCondition6=(#CurrentSection#>30)
IfTrueAction6=[!SetOption RH6 ImageName "#*ImageColor*#1"]
IfFalseAction6=[!SetOption RH6 ImageName "#*ImageColor*#0"]
IfCondition7=(#CurrentSection#>35)
IfTrueAction7=[!SetOption RH7 ImageName "#*ImageColor*#1"]
IfFalseAction7=[!SetOption RH7 ImageName "#*ImageColor*#0"]
IfCondition8=(#CurrentSection#>40)
IfTrueAction8=[!SetOption RH8 ImageName "#*ImageColor*#1"]
IfFalseAction8=[!SetOption RH8 ImageName "#*ImageColor*#0"]
IfCondition9=(#CurrentSection#>45)
IfTrueAction9=[!SetOption RH9 ImageName "#*ImageColor*#1"]
IfFalseAction9=[!SetOption RH9 ImageName "#*ImageColor*#0"]
IfCondition10=(#CurrentSection#>50)
IfTrueAction10=[!SetOption RH10 ImageName "#*ImageColor*#1"]
IfFalseAction10=[!SetOption RH10 ImageName "#*ImageColor*#0"]
IfCondition11=(#CurrentSection#>55)
IfTrueAction11=[!SetOption RH11 ImageName "#*ImageColor*#1"]
IfFalseAction11=[!SetOption RH11 ImageName "#*ImageColor*#0"]
IfCondition12=(#CurrentSection#>60)
IfTrueAction12=[!SetOption RH12 ImageName "#*ImageColor*#1"]
IfFalseAction12=[!SetOption RH12 ImageName "#*ImageColor*#0"]
IfCondition13=(#CurrentSection#>65)
IfTrueAction13=[!SetOption RH13 ImageName "#*ImageColor*#1"]
IfFalseAction13=[!SetOption RH13 ImageName "#*ImageColor*#0"]
IfCondition14=(#CurrentSection#>70)
IfTrueAction14=[!SetOption RH14 ImageName "#*ImageColor*#1"]
IfFalseAction14=[!SetOption RH14 ImageName "#*ImageColor*#0"]
IfCondition15=(#CurrentSection#>75)
IfTrueAction15=[!SetOption RH15 ImageName "#*ImageColor*#1"]
IfFalseAction15=[!SetOption RH15 ImageName "#*ImageColor*#0"]
IfCondition16=(#CurrentSection#>80)
IfTrueAction16=[!SetOption RH16 ImageName "#*ImageColor*#1"]
IfFalseAction16=[!SetOption RH16 ImageName "#*ImageColor*#0"]
IfCondition17=(#CurrentSection#>85)
IfTrueAction17=[!SetOption RH17 ImageName "#*ImageColor*#1"]
IfFalseAction17=[!SetOption RH17 ImageName "#*ImageColor*#0"]
IfCondition18=(#CurrentSection#>90)
IfTrueAction18=[!SetOption RH18 ImageName "#*ImageColor*#1"]
IfFalseAction18=[!SetOption RH18 ImageName "#*ImageColor*#0"]
IfCondition19=(#CurrentSection#>95)
IfTrueAction19=[!SetOption RH19 ImageName "#*ImageColor*#1"]
IfFalseAction19=[!SetOption RH19 ImageName "#*ImageColor*#0"]
IfConditionMode=1

[MeasureLife]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=Lifetime
UpdateDivider=5

[MeasureStatus]
; Measure=Calc
; Formula=Random
; LowBound=0
; HighBound=1
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=Status
UpdateDivider=5
IfCondition=(#CurrentSection#=1)
IfTrueAction=[!SetVariable ImageColor gh][!UpdateMeasure MeasurePercent][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetVariable ImageColor rh][!UpdateMeasure MeasurePercent][!UpdateMeter *][!Redraw]
IfConditionMode=1
DynamicVariables=1

; ========= Meter Styles ==========
[Style]
X=R
Y=r
Path=#@#images\
DynamicVariables=1


; ========= Meters ==========

[BG]
Meter=Image
ImageName=bgM.png
Path="#MPath#\"

[RH1]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH2]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH3]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH4]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH5]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH6]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH7]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH8]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH9]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH10]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH11]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH12]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH13]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH14]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH15]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH16]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH17]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH18]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png

[RH19]
Meter=Image
MeterStyle=Style
ImageName=#ImageColor#0.png
Charging:
gh.png
Not charging:
rh.png
Balala may be able to offer a solution based on Hide/Show if that is how you want to do it.
Hope this helps.
You do not have the required permissions to view the files attached to this post.
David3214
Posts: 14
Joined: December 5th, 2017, 12:16 am

Re: How to show my battery life with Terraria Hearts

Post by David3214 »

Thank you Balala and eclectic-tech, my skin is now working. I decided to go with Eclectic-tech's because it was quite a bit more condensed, but what helped me was everything you both said, not just the code you showed me.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How to show my battery life with Terraria Hearts

Post by eclectic-tech »

Glad to help. There are usually several ways to achieve similar results. :)