It is currently May 1st, 2024, 1:40 am

Three IfActions Possible?

Get help with creating, editing & fixing problems with skins
mistawac
Posts: 14
Joined: August 19th, 2012, 8:05 pm

Three IfActions Possible?

Post by mistawac »

Is there a way for me to incorporate three IfActions in one skin? Example:

I have an image that cycles through 81 images to show a pretty cool effect (see below for source). I've chosen to tweak it to my liking and have it do two things. The first effect I'm working on is have it change color based on the CPU temperature. This effect works if I incorporate only one IfAbove pair and one IfBelow pair. What I want is a third so I can effectively show cool, heating up, and hot temperatures through this visualization.

Here's the working code:

Code: Select all

;===========================================
;  System Temp Variable
;===========================================

[MeasureSpeedTemp5]
Measure=Plugin
Plugin=Plugins\SpeedFanPlugin.dll
SpeedFanType=TEMPERATURE
SpeedFanNumber=5
IfBelowValue=27
IfBelowAction=[!HideMeter ImageMeterYellow][!ShowMeter ImageMeterBlue]
IfAboveValue=28
IfBelowAction=[!HideMeter ImageMeterBlue][!ShowMeter ImageMeterYellow]

;===========================================
;  Image Settings
;===========================================

[ImageMeterBlue]
Meter=Image
ImageName=ImagesFramesBlue\[ImageNumberCalcBlue].png
DynamicVariables=1
X=1865
Y=160

[ImageNumberCalcBlue]
Measure=Calc
Formula=Counter % 81
Substitute="00000":""

[ImageMeterYellow]
Meter=Image
ImageName=ImagesFramesYellow\[ImageNumberCalcYellow].png
DynamicVariables=1
X=1865
Y=160

[ImageNumberCalcYellow]
Measure=Calc
Formula=Counter % 81
Substitute="00000":""
As I said, that works. My problem is implementing a third situation, where it would switch to ImageMeterRed above 38. Ideas?
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Three IfActions Possible?

Post by Kaelri »

Instead of using IfActions, something like this would work for any number of colors:

Code: Select all

;===========================================
;  System Temp Variable
;===========================================

[MeasureSpeedTemp5]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=TEMPERATURE
SpeedFanNumber=5

;===========================================
;  Image Settings
;===========================================

[ImageColorCalc]
Measure=Calc
Formula=(MeasureSpeedTemp5 > 38) ? 3 : ((MeasureSpeedTemp5 > 28) ? 2 : 1)
Substitute="3":"Red","2":"Yellow","1":"Blue"

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 81

[ImageMeter]
Meter=Image
ImageName=ImagesFrames[ImageColorCalc]\[ImageNumberCalc].png
DynamicVariables=1
X=1865
Y=160
mistawac
Posts: 14
Joined: August 19th, 2012, 8:05 pm

Re: Three IfActions Possible?

Post by mistawac »

If you don't mind me asking, what exactly does this do? I noticed you pulled out a bit of what I added and I'm having trouble following the settings.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Three IfActions Possible?

Post by Kaelri »

Sorry, I should have explained a little. :) The key is in the new [ImageColorCalc] measure:

Code: Select all

Formula=(MeasureSpeedTemp5 > 38) ? 3 : ((MeasureSpeedTemp5 > 28) ? 2 : 1)
This is called a "conditional" statement, also known as an "if-then-else" statement. It effectively says:

Code: Select all

If (MeasureSpeedTemp5 > 38) Then
    3
Else
    If (MeasureSpeedTemp5 > 28) Then
        2
    Else
        1
So the formula comes out as "3", "2" or "1", depending on the value of [MeasureSpeedTemp5]. It then uses a substitute to change the numbers into color names: Substitute="3":"Red","2":"Yellow","1":"Blue"

Finally, the image meter can insert the value of [ImageColorCalc] as a dynamic variable, just like it does with [ImageNumberCalc]:

Code: Select all

ImageName=ImagesFrames[ImageColorCalc]\[ImageNumberCalc].png
So this would ultimately come out as e.g. "ImagesFramesBlue\50.png", or "ImagesFramesRed\72.png", or "ImagesFramesYellow\5.png", etc. This saves you the trouble of using separate meters for each color.
mistawac
Posts: 14
Joined: August 19th, 2012, 8:05 pm

Re: Three IfActions Possible?

Post by mistawac »

Damn that's nice! Thank you very much for the help and explanation! I was trying to read it as an If-Then-Else, but couldn't pull it together. As soon as you said that I was able to figure it out.

Thanks again!