It is currently March 24th, 2019, 10:39 pm

Trouble with !SetOption in ImageMeter that is masked

Help with creating, editing & fixing problems with skins
User avatar
Mor3bane
Posts: 572
Joined: May 7th, 2016, 7:32 am

Trouble with !SetOption in ImageMeter that is masked

Mor3bane » November 20th, 2016, 6:13 am

The code is a bit long, but threlevant part is highlighted red.

I have tried magic quotes, but I am still floundering with no result that equals my intention.

Any help would be appreciated :rosegift:

Code: Select all

[Rainmeter]
Update=90
Background=#@#Background
DynamicWindowSize=1
AccurateText=1
Group=Big

[MetaData]
Author=Morbane
Information=*Speed Fan* lists top  to bottom 0, 1, 2, etc

[MeasureCPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=2
SpeedFanScale=C
IfCondition=MeasureCPUTemp > 59
IfTrueAction=[!SetOption MeterSpeedFan FontColor 190,40,40]
IfFalseAction=[!SetOption MeterSpeedFan FontColor 23,153,140]
IfCondition2=MeasureCPUTemp >= 50
IfTrueAction2=[!SetOption MeterSpeedFan FontColor 240,120,26,248]
IfFalseAction2=[!SetOption MeterSpeedFan FontColor 23,153,140]
Substitute="(.)$":"\1c","^0+c$":"GetSpeedFan"
RegExpSubstitute=1

[MeasureGPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=0
SpeedFanScale=C
IfCondition=MeasureGPUTemp > 59
IfTrueAction=[!SetOption MeterSpeedFan1 FontColor 190,40,40]
IfFalseAction=[!SetOption MeterSpeedFan1 FontColor 23,153,140]
IfCondition2=MeasureGPUTemp >= 50
IfTrueAction2=[!SetOption MeterSpeedFan1 FontColor 240,120,26,248]
IfFalseAction2=[!SetOption MeterSpeedFan1 FontColor 23,153,140]

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 5
DynamicVariables=1


[MainCover]
Meter=Image
MaskImageName=#@#mask.png
ImageName="#@#dwya\dwya-[ImageNumberCalc].png"
AntiAlias=1
Y=24
X=24
W=210
H=209
IfCondition=MeasureGPUTemp < 45
IfTrueAction=[!SetOption ImageNumberCalc Formula "Counter % 18"][!SetOption MainCover ImageName "#@#snow\snow-[ImageNumberCalc].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
IfCondition2=MeasureGPUTemp > 49
IfTrueAction2-[!SetOption ImageNumberCalc Formula "Counter % 20"][!SetOption MainCover ImageName "#@#fire\fire-[ImageNumberCalc].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
DynamicVariables=1

[MeterText]
Meter=String
Text=CPU Temp:
Fontsize=24
FontFace=Astronaut
FontColor=23,153,140
AntiAlias=1 
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
y=70
DynamicVariables=1

[MeterText1]
Meter=String
Text=GPU Temp:
Fontsize=24
FontFace=Astronaut
FontColor=23,153,140
AntiAlias=1 
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
y=130
DynamicVariables=1

[MeterSpeedFan]
Meter=String
MeasureName=MeasureCPUTemp
FontSize=24
FontColor=23,153,140
FontFace=Astronaut
StringStyle=normal
AntiAlias=1
Text="%1"
y=100
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
DynamicVariables=1

[MeterSpeedFan1]
Meter=String
MeasureName=MeasureGPUTemp
FontSize=24
FontColor=23,153,140
FontFace=Astronaut
StringStyle=normal
AntiAlias=1
Text="%1c"
y=160
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
DynamicVariables=1
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself
User avatar
Mor3bane
Posts: 572
Joined: May 7th, 2016, 7:32 am

Re: Trouble with !SetOption in ImageMeter that is masked

Mor3bane » November 20th, 2016, 6:15 am

Mor3bane wrote:The code is a bit long, but threlevant part is MainCover.

I have tried magic quotes, but I am still floundering with no result that equals my intention.

Any help would be appreciated :rosegift:

Code: Select all

[Rainmeter]
Update=90
Background=#@#Background
DynamicWindowSize=1
AccurateText=1
Group=Big

[MetaData]
Author=Morbane
Information=*Speed Fan* lists top  to bottom 0, 1, 2, etc

[MeasureCPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=2
SpeedFanScale=C
IfCondition=MeasureCPUTemp > 59
IfTrueAction=[!SetOption MeterSpeedFan FontColor 190,40,40]
IfFalseAction=[!SetOption MeterSpeedFan FontColor 23,153,140]
IfCondition2=MeasureCPUTemp >= 50
IfTrueAction2=[!SetOption MeterSpeedFan FontColor 240,120,26,248]
IfFalseAction2=[!SetOption MeterSpeedFan FontColor 23,153,140]
Substitute="(.)$":"\1c","^0+c$":"GetSpeedFan"
RegExpSubstitute=1

[MeasureGPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=0
SpeedFanScale=C
IfCondition=MeasureGPUTemp > 59
IfTrueAction=[!SetOption MeterSpeedFan1 FontColor 190,40,40]
IfFalseAction=[!SetOption MeterSpeedFan1 FontColor 23,153,140]
IfCondition2=MeasureGPUTemp >= 50
IfTrueAction2=[!SetOption MeterSpeedFan1 FontColor 240,120,26,248]
IfFalseAction2=[!SetOption MeterSpeedFan1 FontColor 23,153,140]

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 5
DynamicVariables=1


[MainCover]
Meter=Image
MaskImageName=#@#mask.png
ImageName="#@#dwya\dwya-[ImageNumberCalc].png"
AntiAlias=1
Y=24
X=24
W=210
H=209
IfCondition=MeasureGPUTemp < 45
IfTrueAction=[!SetOption ImageNumberCalc Formula "Counter % 18"][!SetOption MainCover ImageName "#@#snow\snow-[ImageNumberCalc].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
IfCondition2=MeasureGPUTemp > 49
IfTrueAction2-[!SetOption ImageNumberCalc Formula "Counter % 20"][!SetOption MainCover ImageName "#@#fire\fire-[ImageNumberCalc].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
DynamicVariables=1

[MeterText]
Meter=String
Text=CPU Temp:
Fontsize=24
FontFace=Astronaut
FontColor=23,153,140
AntiAlias=1 
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
y=70
DynamicVariables=1

[MeterText1]
Meter=String
Text=GPU Temp:
Fontsize=24
FontFace=Astronaut
FontColor=23,153,140
AntiAlias=1 
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
y=130
DynamicVariables=1

[MeterSpeedFan]
Meter=String
MeasureName=MeasureCPUTemp
FontSize=24
FontColor=23,153,140
FontFace=Astronaut
StringStyle=normal
AntiAlias=1
Text="%1"
y=100
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
DynamicVariables=1

[MeterSpeedFan1]
Meter=String
MeasureName=MeasureGPUTemp
FontSize=24
FontColor=23,153,140
FontFace=Astronaut
StringStyle=normal
AntiAlias=1
Text="%1c"
y=160
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
DynamicVariables=1
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself
User avatar
balala
Rainmeter Sage
Posts: 7914
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trouble with !SetOption in ImageMeter that is masked

balala » November 20th, 2016, 7:18 am

I'm not sure finally if you got solved your own question, but I have a few things to say about your code:
  • the IfCondition options have to be used into measures, they won't work in meters. So you'll have move these options from the [MainCover] to a measure.
  • in the mentioned IfTrueAction options, replace the following two bangs: [!SetOption MainCover ImageName "#@#snow\snow-[ImageNumberCalc].jpg"] and [!SetOption MainCover ImageName "#@#fire\fire-[ImageNumberCalc].jpg"] with [!SetOption MainCover ImageName "#@#snow\snow-[[color=#FF0000]*[/color]ImageNumberCalc[color=#FF0000]*[/color]].jpg"] and [!SetOption MainCover ImageName "#@#fire\fire-[[color=#FF0000]*[/color]ImageNumberCalc[color=#FF0000]*[/color]].jpg"]. Here I used the escaping character - read the [Measures] and !SetOption (and the Variables and !SetOption) sections here.
  • in the last IfTrueAction, you've put a -, instead of the =. Replace it.
  • when you set the color of the fonts with !SetOption bangs, usually it's a good idea to include the color codes into quotation marks, because although these color codes contain just numbers, they are in fact strings (I'm talking about the IfTrueAction and IfFalseAction options of the [MeasureCPUTemp] and [MeasureGPUTemp] measures).
User avatar
jsmorley
Developer
Posts: 19076
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Trouble with !SetOption in ImageMeter that is masked

jsmorley » November 20th, 2016, 2:30 pm

balala wrote: when you set the color of the fonts with !SetOption bangs, usually it's a good idea to include the color codes into quotation marks, because although these color codes contain just numbers, they are in fact strings (I'm talking about the IfTrueAction and IfFalseAction options of the [MeasureCPUTemp] and [MeasureGPUTemp] measures).
I agree with Balala entirely on this. It is a good habit, a good practice, to just always enclose any "values" being set in a !Bang in quotes. If you don't just make this something you do automatically, it's going to bite you sooner or later. I even enclose plain numbers as values, since I don't really need them with a number but might well with a formula. If it is just muscle-memory that the value parameter in a !Bang is enclosed, you don't every have to do that "What? Oh, yeah..." thing.
User avatar
Mor3bane
Posts: 572
Joined: May 7th, 2016, 7:32 am

Re: Trouble with !SetOption in ImageMeter that is masked

Mor3bane » November 21st, 2016, 2:39 am

Hi Guys,
Thanks for the replies, and the advice, and the code segments.

Unfortunately, only the default ImageName is working.

Code: Select all

[Rainmeter]
Update=90
Background=#@#Background
DynamicWindowSize=1
AccurateText=1
Group=Big

[MetaData]
Author=Morbane
Information=*Speed Fan* lists top  to bottom 0, 1, 2, etc

[MeasureCPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=2
SpeedFanScale=C
IfCondition=MeasureCPUTemp > 59
IfTrueAction=[!SetOption MeterSpeedFan FontColor "190,40,40"]
IfFalseAction=[!SetOption MeterSpeedFan FontColor "23,153,140"]
IfCondition2=MeasureCPUTemp >= 50
IfTrueAction2=[!SetOption MeterSpeedFan FontColor "240,120,26,248"]
IfFalseAction2=[!SetOption MeterSpeedFan FontColor "23,153,140"]
Substitute="(.)$":"\1c","^0+c$":"GetSpeedFan"
RegExpSubstitute=1

[MeasureGPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=0
SpeedFanScale=C
IfCondition=MeasureGPUTemp > 59
IfTrueAction=[!SetOption MeterSpeedFan1 FontColor "190,40,40"]
IfFalseAction=[!SetOption MeterSpeedFan1 FontColor "23,153,140"]
IfCondition2=MeasureGPUTemp >= 50
IfTrueAction2=[!SetOption MeterSpeedFan1 FontColor "240,120,26,248"]
IfFalseAction2=[!SetOption MeterSpeedFan1 FontColor "23,153,140"]

[ImageNumberCalc]
Measure=Calc
Formula=Counter % 5
DynamicVariables=1


[MainCover]
Meter=Image
MaskImageName=#@#mask.png
ImageName="#@#dwya\dwya-[ImageNumberCalc].png"
AntiAlias=1
Y=24
X=24
W=210
H=209
IfCondition=MeasureGPUTemp < 45
IfTrueAction=[!SetOption ImageNumberCalc Formula "Counter % 18"][!SetOption MainCover ImageName "#@#snow\snow-[*ImageNumberCalc*].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
IfCondition2=MeasureGPUTemp > 49
IfTrueAction2=[!SetOption ImageNumberCalc Formula "Counter % 20"][!SetOption MainCover ImageName "#@#fire\fire-[*ImageNumberCalc*].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
DynamicVariables=1

[MeterText]
Meter=String
Text=CPU Temp:
Fontsize=24
FontFace=Astronaut
FontColor=23,153,140
AntiAlias=1
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
y=70
DynamicVariables=1

[MeterText1]
Meter=String
Text=GPU Temp:
Fontsize=24
FontFace=Astronaut
FontColor=23,153,140
AntiAlias=1
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
y=130
DynamicVariables=1

[MeterSpeedFan]
Meter=String
MeasureName=MeasureCPUTemp
FontSize=24
FontColor=23,153,140
FontFace=Astronaut
StringStyle=normal
AntiAlias=1
Text="%1"
y=100
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
DynamicVariables=1

[MeterSpeedFan1]
Meter=String
MeasureName=MeasureGPUTemp
FontSize=24
FontColor=23,153,140
FontFace=Astronaut
StringStyle=normal
AntiAlias=1
Text="%1c"
y=160
StringAlign=Center
x=(#CURRENTCONFIGWIDTH#/2)
DynamicVariables=1
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself
mak_kawa
Posts: 226
Joined: December 30th, 2015, 9:47 am

Re: Trouble with !SetOption in ImageMeter that is masked

mak_kawa » November 21st, 2016, 8:42 am

Hi Mor3bane.

As balala said, IfCondition phrase can not be placed in meters. Move it to appropriate measure section, maybe MeasureGPUTemp?
User avatar
balala
Rainmeter Sage
Posts: 7914
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trouble with !SetOption in ImageMeter that is masked

balala » November 21st, 2016, 2:51 pm

Mor3bane, as mak_kawa also said, you still have in your last code some IfConditions in [MainCover], which is a meter and as such, the IfConditions won't work, if you put them there. As mak_kawa suggested, you can move these options into the [MeasureGPUTemp] measure (there, because the conditions are related to this measure), but I'm not sure I can follow what you'd like to do and on what limits.
An important thing you should take into account here, is that it not seem a good practice to use multiple IfConditions, all of them with the appropriate IfTrueAction and IfFalseAction. In my opinion the best approach would be to use either one single IfCondition with IfTrueAction / IfFalseAction, or if you use multiple IfConditions, use just the appropriate IfTrueActions. Otherwise you'll encounter a lot of problems. Eg, in the [MeasureGPUTemp] measure of your last code, which IfTrueAction / IfFalseAction will be executed when the value of the measure will be 30, because in this case, both conditions are false? The response is probably both, but because IfFalseAction2 is the last, this will have effect. But in my opinion, this is not a desirable approach (again: this is just my opinion). Instead, I'd do something like the following:

Code: Select all

[MeasureGPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=2
SpeedFanScale=C
IfCondition=(MeasureGPUTemp<50)
IfTrueAction=[!SetOption MeterSpeedFan FontColor "23,153,140"]
IfCondition2=((MeasureGPUTemp>=50)&&(MeasureGPUTemp<=59))
IfTrueAction2=[!SetOption MeterSpeedFan FontColor "240,120,26,248"]
IfCondition3=(MeasureGPUTemp>59)
IfTrueAction3=[!SetOption MeterSpeedFan FontColor "190,40,40"]
See that here any value of the measure, will be clearly included into one and just one IfCondition.
Now if you'll move the IfConditions from the [MainCover] meter (where they don't belong), you have to decide how you want to set the limits and what you'd like to do when any condition become true. Eg, the following example is not the best, it don't fully complying with original limits, but I think it can be a start:

Code: Select all

[MeasureGPUTemp]
Measure=Plugin
Plugin=SpeedFanPlugin
SpeedFanType=Temperature
SpeedFanNumber=2
SpeedFanScale=C
IfCondition=(MeasureGPUTemp<50)
IfTrueAction=[!SetOption MeterSpeedFan FontColor "23,153,140"][!SetOption ImageNumberCalc Formula "Counter % 18"][!SetOption MainCover ImageName "#@#snow\snow-[*ImageNumberCalc*].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
IfCondition2=((MeasureGPUTemp>=50)&&(MeasureGPUTemp<=59))
IfTrueAction2=[!SetOption MeterSpeedFan FontColor "240,120,26,248"][!SetOption ImageNumberCalc Formula "Counter % 20"][!SetOption MainCover ImageName "#@#fire\fire-[*ImageNumberCalc*].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
IfCondition3=(MeasureGPUTemp>59)
IfTrueAction3=[!SetOption MeterSpeedFan FontColor "190,40,40"][!SetOption ImageNumberCalc Formula "Counter % 20"][!SetOption MainCover ImageName "#@#fire\fire-[*ImageNumberCalc*].jpg"][!UpdateMeasure MainCover][!UpdateMeasure ImageNumberCalc][!Redraw]
If you'll use this measure, you should remove, not move the IfConditions of the [MainCover] meter.
User avatar
Mor3bane
Posts: 572
Joined: May 7th, 2016, 7:32 am

Re: Trouble with !SetOption in ImageMeter that is masked

Mor3bane » November 23rd, 2016, 1:14 pm

THANKS Balala :thumbup:

Works proper right now.

Cheers,
Mor
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself
User avatar
balala
Rainmeter Sage
Posts: 7914
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trouble with !SetOption in ImageMeter that is masked

balala » November 23rd, 2016, 1:38 pm

Glad to help.