It is currently May 6th, 2024, 5:28 pm

[Solved] Multiple IfAboveActions/IfBelowActions

Get help with creating, editing & fixing problems with skins
User avatar
Yggdrasil
Posts: 24
Joined: June 25th, 2011, 5:09 pm

[Solved] Multiple IfAboveActions/IfBelowActions

Post by Yggdrasil »

Hello,
I am working on the temperature sensor part of my skin, and I don't know how to change the images depending on the measured temperature. My code is the following:

Code: Select all

[HDDTEMPACTION]
MeasureName=MTemp3
IfBelowValue=40
IfBelowAction=!Execute [!RainmeterHideMeter HDDMED][!RainmeterHideMeter HDDHOT][!RainmeterHideMeter HDDHIGH][!RainmeterShowMeter HDDLOW]
IfAboveValue=39
IfAboveAction=!Execute [!RainmeterHideMeter HDDLOW][!RainmeterHideMeter HDDHOT][!RainmeterHideMeter HDDHIGH][!RainmeterShowMeter HDDMED]
IfAboveValue=44
IfAboveAction=!Execute [!RainmeterHideMeter HDDLOW][!RainmeterHideMeter HDDMED][!RainmeterHideMeter HDDHIGH][!RainmeterShowMeter HDDHOT]
IfAboveValue=49
IfAboveAction=!Execute [!RainmeterHideMeter HDDLOW][!RainmeterHideMeter HDDHOT][!RainmeterHideMeter HDDMED][!RainmeterShowMeter HDDHIGH]

[HDDLOW]
Meter=Image
ImageName=0.png
X=5r
Y=10r
Hidden=0

[HDDMED]
Meter=Image
ImageName=1.png
X=5r
Y=10r
Hidden=1

[HDDHOT]
Meter=Image
ImageName=2.png
X=5r
Y=10r
Hidden=1

[HDDHIGH]
Meter=Image
ImageName=3.png
X=5r
Y=10r
Hidden=1
Unfortunately, whatever is the temperature (now 41°C), it shows 0.png (HDDLOW) . Seems it doesn't update itself. Any idea?
Image
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Multiple IfAboveActions/IfBelowActions

Post by Kaelri »

There are a few problems here. First, your [HDDTEMPACTION] section is neither a meter nor a measure, which means it can't act on anything. Second, you unfortunately can't have multiple IfAboveValues and IfAboveActions. Rainmeter will simply use the first one and ignore the others.

What I would do is turn this section into a CALC measure, and use a series of conditionals to return a different value when the temperature falls into your defined ranges. For example:

Code: Select all

[HDDTEMPACTION]
Measure=CALC
Formula=MTemp3 < 40 ? 1 : (MTemp3 < 45 ? 2 : (MTemp3 < 50 ? 3 : 4))
Substitute=".0":"","0":""
This formula will return "1", if the temperature is below 40; "2" if between 40-44; "3" if 45-49; and "4" if 50 or above. The Substitute line tells it to strip the decimals.

With this, you only need a single image meter referencing a filename, based on the Calc measure:

Code: Select all

[HDDIMAGE]
Meter=Image
MeasureName=HDDTEMPACTION
ImageName=%1.png
X=5r
Y=10r
Then just rename your images 1.png, 2.png, 3.png and 4.png.