It is currently March 29th, 2024, 12:57 pm
Get help with creating, editing & fixing problems with skins
StArL0rd84
Posts: 424 Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.
Post
by StArL0rd84 » December 31st, 2018, 10:07 am
A while back i came across a neat way of making an ordinary 2 way toggle switch, but now i need a 3 way.
Looked into counters but could not find a elegant solution there.
I am hoping the following code can be converted into a 3 way somehow...
I need it in this case because there's a Off setting besides just Blur and Acrylic.
Code: Select all
[Variables]
BlurTypeState=0
[mBlurType]
Measure=Calc
Formula=#BlurTypeState#
IfEqualValue=0
IfEqualAction=[!SetVariable BlurType Blur][!WriteKeyValue Variables BlurType "Blur" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
IfAboveValue=0
IfAboveAction=[!SetVariable BlurType Acrylic][!WriteKeyValue Variables BlurType "Acrylic" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
DynamicVariables=1
UpdateDivider=-1
Group=Blur
LeftMouseDownAction=[!SetVariable BlurTypeState "(1-#BlurTypeState#)"][!WriteKeyValue Variables BlurTypeState "(1-#BlurTypeState#)" "#Var#"][!UpdateMeasureGroup Blur][!UpdateMeter *][!Redraw]
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </> ))
balala
Rainmeter Sage
Posts: 16110 Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania
Post
by balala » December 31st, 2018, 11:02 am
Beside the IfEqual and IfAbove, there is a third set of options:
IfBelow . Using this, your code should look in the following form:
Code: Select all
[Variables]
BlurTypeState=0
[mBlurType]
Measure=Calc
Formula=#BlurTypeState#
IfBelowValue=1
IfBelowAction=[!SetVariable BlurType Blur][!WriteKeyValue Variables BlurType "None" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
IfEqualValue=1
IfEqualAction=[!SetVariable BlurType Blur][!WriteKeyValue Variables BlurType "Blur" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
IfAboveValue=1
IfAboveAction=[!SetVariable BlurType Acrylic][!WriteKeyValue Variables BlurType "Acrylic" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
LeftMouseDownAction=[!SetVariable BlurTypeState "((1+#BlurTypeState#)%3)"][!WriteKeyValue Variables BlurTypeState "((1+#BlurTypeState#)%3)" "#Var#"][!UpdateMeasureGroup Blur][!UpdateMeter *][!Redraw]
DynamicVariables=1
UpdateDivider=-1
Group=Blur
But instead of using IfAction, you should have to use
IfConditions , which is much more reliable and can have as many conditions as needed. Using these instead of IfAction, the above code would look like:
Code: Select all
[Variables]
BlurTypeState=0
[mBlurType]
Measure=Calc
Formula=#BlurTypeState#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetVariable BlurType Blur][!WriteKeyValue Variables BlurType "None" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
IfCondition2=(#CURRENTSECTION#=0)
IfTrueAction2=[!SetVariable BlurType Blur][!WriteKeyValue Variables BlurType "Blur" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
IfCondition3=(#CURRENTSECTION#=0)
IfTrueAction3=[!SetVariable BlurType Blur][!WriteKeyValue Variables BlurType "Acrylic" #Var#"][!UpdateMeasure FrostedGlass][!UpdateMeter DescBlurBehind][!Redraw]
LeftMouseDownAction=[!SetVariable BlurTypeState "((1+#BlurTypeState#)%3)"][!WriteKeyValue Variables BlurTypeState "((1+#BlurTypeState#)%3)" "#Var#"][!UpdateMeasureGroup Blur][!UpdateMeter *][!Redraw]
DynamicVariables=1
UpdateDivider=-1
Group=Blur
Note that I also rewrote the formula of the BlurTypeState variable into the LeftMouseUpAction option. With this new formula the value of the variable varies from 0 to 2, as needed.
StArL0rd84
Posts: 424 Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.
Post
by StArL0rd84 » December 31st, 2018, 1:11 pm
Hey thanks!
exactly what i needed
The
((1+#BlurState#)%3) trick is really nice. Can now make a 1 million way toggle...
3way.gif
You do not have the required permissions to view the files attached to this post.
([mWorkTime] = 1 ? #Work# : ([mEnergyLoss:%] >= 70% ? #Chillmode# : </> ))
balala
Rainmeter Sage
Posts: 16110 Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania
Post
by balala » December 31st, 2018, 2:31 pm
StArL0rd84 wrote: ↑ December 31st, 2018, 1:11 pm
Can now make a 1 million way toggle...
Exactly. Just note that if in the above formula you are using 3, the returned values go from 0 to 2 (one below).