It is currently November 15th, 2019, 11:31 am

Double IfCondition Not Working?

General topics related to Rainmeter.
spykyvenator
Posts: 4
Joined: December 2nd, 2018, 4:46 pm

Double IfCondition Not Working?

spykyvenator » August 7th, 2019, 2:35 pm

I tried to make a clickable image that changes the action based on the location on which I clicked it, but it wouldn't work.
I wanted to make the Hogwarts platform 9 3/4 sign with clickable houses on the Hogwarts logo.

here you've got the code:

Code: Select all

[rainmeter]
update=500

[Variables]
cirlcemid=600
MouseY=0
MouseX=0

[G_Logo]
Meter=Image
ImageName=#@#pictures\G.png
Group=G
X=1000
Y=1000
H=300
Y=300
Hidden=1

[Hogwarts Logo]
meter=image
imagename=#@#Pictures/Hogwarts_Logo.png
x=10
y=10
W=500
H=500
LeftMouseUpAction=[!SetVariable MouseY $MouseY$][!SetVariable MouseX $MouseX$]
IfCondition=(#MouseX# < 250) && (#MouseY# < 270)
IfTrueAction=[!ShowMeterGroup G][!Redraw]

[VarText]
meter=string
Meterstyle=StyleTimeText
Fontsize=40
x=0
y=0
W=550
H=550
Text=#MouseX#,#MouseY#
DynamicVariables=1
Last edited by balala on August 7th, 2019, 3:50 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting code snippets. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 9053
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Double IfCondition Not Working?

balala » August 7th, 2019, 3:59 pm

spykyvenator wrote:
August 7th, 2019, 2:35 pm
I tried to make a clickable image that changes the action based on the location on which I clicked it, but it wouldn't work.
I wanted to make the Hogwarts platform 9 3/4 sign with clickable houses on the Hogwarts logo.
IfCondition can't be used on meters, just on measures. You added it for nothing to the [Hogwarts Logo] meter, it doesn't work. Add any Calc measure to your code and add it there. For instance, add the following measure:

Code: Select all

[MyMeasure]
Measure=Calc
Formula=1
IfCondition=(#MouseX# < 250) && (#MouseY# < 270)
IfTrueAction=[!ShowMeterGroup G][!Redraw]
If you do so, remove the IfCondition from the [Hogwarts Logo] meter.
In addition to that, I also would add a bang to the LeftMouseUpAction to update immediately the newly added measure when you click the meter:

Code: Select all

[Hogwarts Logo]
...
LeftMouseUpAction=[!SetVariable MouseY $MouseY$][!SetVariable MouseX $MouseX$][!UpdateMeasure "MyMeasure"]
Also note that although not completely forbiden, nor a good idea is to use spaces into section names. I'd replace the [Hogwarts Logo] meter name with something like [HogwartsLogo], or [Hogwarts_Logo], or something else, with no space. Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=31683&p=160586&hilit=spaces+section+name#p160586
User avatar
Active Colors
Moderator
Posts: 529
Joined: February 16th, 2012, 3:32 am

Re: Double IfCondition Not Working?

Active Colors » August 7th, 2019, 4:02 pm

Additionally to what balala just said you have a typo in [G_Logo] meter.

Code: Select all

[G_Logo]
Meter=Image
ImageName=#@#pictures\G.png
Group=G
X=1000
Y=1000
H=300
Y=300
Hidden=1
Look closely. There are two Y coordinates. I believe it is just a typo, but this typo is breaking the meter and it will not be shown by your [!ShowMeterGroup G] bang.
User avatar
balala
Rainmeter Sage
Posts: 9053
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Double IfCondition Not Working?

balala » August 7th, 2019, 4:42 pm

Active Colors wrote:
August 7th, 2019, 4:02 pm
but this typo is breaking the meter and it will not be shown by your [!ShowMeterGroup G] bang.
But yes, it will be. In such cases the first value of the doubled option is used. If you show a meter / more meters through !ShowMeter / !ShowMeterGroup bangs even if any of its / their options are doubled, the meter(s) are anyway shown. As said, using always the first value of the doubled option(s).
spykyvenator
Posts: 4
Joined: December 2nd, 2018, 4:46 pm

Re: Double IfCondition Not Working?

spykyvenator » August 8th, 2019, 9:22 am

Thank you for your quick answers I wasn't aware of the if condition not wroking on Meters.
I aslo needed a DynamicVariable on the measure to make it work.
User avatar
balala
Rainmeter Sage
Posts: 9053
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Double IfCondition Not Working?

balala » August 8th, 2019, 11:36 am

spykyvenator wrote:
August 8th, 2019, 9:22 am
I aslo needed a DynamicVariable on the measure to make it work.
Right. Sorry, my mistake I forgot to tell it is needed in order to get the measure working properly.