It is currently May 8th, 2024, 10:55 pm

[solved] Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off.

Get help with creating, editing & fixing problems with skins
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

[solved] Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off.

Post by CodeCode »

Hello,
I got so far into this a measure that works impirically as coded, and I am hoping to either continue from there, or to try another run into the lua great beyond.

Code: Select all

[MeasureCorners]
Measure=Calc
IfCondition=(#2L# = 50)
IfTrueAction=[!SetOptionGroup "AUL" "Hidden" "0" ][!SetOptionGroup "ALL" "Hidden" "0" ][!Update]
IfFalseAction=[!SetOptionGroup "AUL" "Hidden" "1" ][!SetOptionGroup "ALL" "Hidden" "1" ][!Update]
IfCondition2=(#2T# = 50)
IfTrueAction2=[!SetOptionGroup "AUL" "Hidden" "0" ][!SetOptionGroup "AUR" "Hidden" "0" ][!Update]
IfFalseAction2=[!SetOptionGroup "AUL" "Hidden" "1" ][!SetOptionGroup "AUR" "Hidden" "1" ][!Update]
IfCondition3=(#2R# = 50)
IfTrueAction3=[!SetOptionGroup "AUR" "Hidden" "0" ][!SetOptionGroup "ALR" "Hidden" "0" ][!Update]
IfFalseAction3=[!SetOptionGroup "AUR" "Hidden" "1" ][!SetOptionGroup "ALR" "Hidden" "1" ][!Update]
IfCondition4=(#2B# = 50)
IfTrueAction4=[!SetOptionGroup "ALR" "Hidden" "0" ][!SetOptionGroup "ALL" "Hidden" "0" ][!Update]
IfFalseAction4=[!SetOptionGroup "ALR" "Hidden" "1" ][!SetOptionGroup "ALL" "Hidden" "1" ][!Update]
DynamicVariables=1
So, I can clearly see that this is only working with the base 4 states. The abbreviations are for AUpperLeft (AUL) AUpperRight (AUR) ALowerLeft (ALL) ALowerRight (ALR).

The ifconditions are the four base state variables 2L 2T 2R 2B.

This is meant to work by testing the four base states. But my problem is that the other 8 states look like these: (sort of)

IfCondition=(#2L# = 50) && (#2T# = 50)
As shown above the four states each manage 2 meters to show or hide, but that case is that it can be meant to work like a square sometimes when two of the states overlap like this for example; 2L and 2T. My ifcondition logic would have to include only 1 of the two 'corners' when 2 conditions overlap.

I hope my descriptions are enough to go by.

Thanks
CC
Last edited by CodeCode on October 15th, 2023, 11:21 am, edited 1 time in total.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
balala
Rainmeter Sage
Posts: 16206
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by balala »

I'd recommend 16 IfConditions, each testing all four variables, but each having just an IfTrueAction, withi no IfFalseAction. When using multiple IfConditions into a measure, seems extremely confusing to use both, IfTrueAction and IfFalseAction on each IfCondition. Definitely can be used, but makes things confusing. So maybe something like this might do the job:

Code: Select all

[MeasureCorners]
Measure=Calc
IfCondition=((#2L#=50)&&(#2T#=50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction=
IfCondition2=((#2L#<>50)&&(#2T#=50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction2=
IfCondition3=((#2L#=50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction3=
IfCondition4=((#2L#=50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction4=
IfCondition5=((#2L#=50)&&(#2T#=50)&&(#2R#=50)&&(#2B#<>50))
IfTrueAction5=
IfCondition6=((#2L#<>50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction6=
IfCondition7=((#2L#<>50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction7=
IfCondition8=((#2L#<>50)&&(#2T#=50)&&(#2R#=50)&&(#2B#<>50))
IfTrueAction8=
IfCondition9=((#2L#=50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction9=
IfCondition10=((#2L#=50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#<>50))
IfTrueActio10=
IfCondition11=((#2L#=50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction11=
IfCondition12=((#2L#<>50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction12=
IfCondition13=((#2L#<>50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#<>50))
IfTrueAction13=
IfCondition14=((#2L#<>50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction14=
IfCondition15=((#2L#=50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction15=
IfCondition16=((#2L#<>50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction16=
DynamicVariables=1
I didn't add the IfTrueActions, you have to add them as you wish. Even if this approach uses 16 IfConditions for the four variables, makes the conditions and the involved actions, much more clear.

Additional notes:
  • Instead of setting the Hidden options of the meters to hide or show them, a much more natural (at least in my opinion) approach is to use the !HideMeterGroup and !ShowMeterGroup bangs.
  • When showing or hiding meters (no matter how do you do this, by setting their Hidden options, or by using the !HideMeter / !ShowMeter / !HideMeterGroup, / !ShowMeterGroup bangs), updating the whole skin is completely useless. A redraw of the skin (done by a !Redraw bang) is completely enough. So, replace the final [!Update] bangs by [!Redraw].
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by CodeCode »

balala wrote: October 15th, 2023, 7:52 am I'd recommend 16 IfConditions, each testing all four variables, but each having just an IfTrueAction, withi no IfFalseAction. When using multiple IfConditions into a measure, seems extremely confusing to use both, IfTrueAction and IfFalseAction on each IfCondition. Definitely can be used, but makes things confusing. So maybe something like this might do the job:

Code: Select all

[MeasureCorners]
Measure=Calc
IfCondition=((#2L#=50)&&(#2T#=50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction=
IfCondition2=((#2L#<>50)&&(#2T#=50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction2=
IfCondition3=((#2L#=50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction3=
IfCondition4=((#2L#=50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction4=
IfCondition5=((#2L#=50)&&(#2T#=50)&&(#2R#=50)&&(#2B#<>50))
IfTrueAction5=
IfCondition6=((#2L#<>50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#=50))
IfTrueAction6=
IfCondition7=((#2L#<>50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction7=
IfCondition8=((#2L#<>50)&&(#2T#=50)&&(#2R#=50)&&(#2B#<>50))
IfTrueAction8=
IfCondition9=((#2L#=50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction9=
IfCondition10=((#2L#=50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#<>50))
IfTrueActio10=
IfCondition11=((#2L#=50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction11=
IfCondition12=((#2L#<>50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#=50))
IfTrueAction12=
IfCondition13=((#2L#<>50)&&(#2T#<>50)&&(#2R#=50)&&(#2B#<>50))
IfTrueAction13=
IfCondition14=((#2L#<>50)&&(#2T#=50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction14=
IfCondition15=((#2L#=50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction15=
IfCondition16=((#2L#<>50)&&(#2T#<>50)&&(#2R#<>50)&&(#2B#<>50))
IfTrueAction16=
DynamicVariables=1
I didn't add the IfTrueActions, you have to add them as you wish. Even if this approach uses 16 IfConditions for the four variables, makes the conditions and the involved actions, much more clear.

Additional notes:
  • Instead of setting the Hidden options of the meters to hide or show them, a much more natural (at least in my opinion) approach is to use the !HideMeterGroup and !ShowMeterGroup bangs.
  • When showing or hiding meters (no matter how do you do this, by setting their Hidden options, or by using the !HideMeter / !ShowMeter / !HideMeterGroup, / !ShowMeterGroup bangs), updating the whole skin is completely useless. A redraw of the skin (done by a !Redraw bang) is completely enough. So, replace the final [!Update] bangs by [!Redraw].
Yep, my versions/permutations were also around 16 ifconditions - but the thing I am drawn to in your excellent example are the <> evaluators - that means notequalto, yea?

For some reason I thought notequal was not included in rainmeter. If that was the case, I think a lot of logic I struggled with in the past will be easier now.

Thank You!
:great:
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7211
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by Yincognito »

balala wrote: October 15th, 2023, 7:52 am When showing or hiding meters (no matter how do you do this, by setting their Hidden options, or by using the !HideMeter / !ShowMeter / !HideMeterGroup, / !ShowMeterGroup bangs), updating the whole skin is completely useless. A redraw of the skin (done by a !Redraw bang) is completely enough. So, replace the final [!Update] bangs by [!Redraw].
Small but important note here...

Updating the whole skin via !Update might be completely useless because it won't update sections with a non-default update divider (like discussed in another thread), but a !Redraw will NOT be enough if setting the Hidden option, you'll have to !UpdateMeter beforehand as well. After setting an option, a section MUST be updated to have that changed option applied immediately, even if it's the Hidden option.

Of course, when using the !HideMeter / !ShowMeter / !ToggleMeter bangs, a !Redraw is enough, since apparently these bangs internally include updating the target meter as well. Just not after setting an option (like Hidden, in this case).

Yeah, I know, the manual omits talking about this, in both the bang description and the codes from its guide - it just shows that you can't always take every info for granted. You can easily test what I described above in a skin having an Image meter setting the Hidden option of another such meter and redrawing, and an skin update of, say, 5000 ms, to make the effect more noticeable.
Last edited by Yincognito on October 15th, 2023, 1:06 pm, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by CodeCode »

Just thought to say that balala's example works perfectly.

Another new idea seeing progress - makes my hobby-day. :great:
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by CodeCode »

Yincognito wrote: October 15th, 2023, 11:08 am Small but important note here...

Updating the whole skin via !Update might be completely useless because it won't update sections with a non-default update divider (like discussed in another thread),
but a !Redraw will NOT be enough if setting the Hidden option, you'll have to !UpdateMeter beforehand as well. After setting an option, a section MUST be updated to have that changed option applied immediately, even if it's the Hidden option.

Of course, when using the !HideMeter / !ShowMeter / !ToggleMeter bangs, a !Redraw is enough, since apparently these bangs internally include updating the target meter as well. Just not after setting an option (like Hidden, in this case).

Yeah, I know, the manual omits talking about this, in both the bang description and the codes from its guide - it just shows that you can't always take every info for granted. You can easily test what I described above in a skin having an Image meter setting the Hidden option of another such meter and redrawing, and an skin update of, say, 5000 ms, to make the effect more noticeable.
I went with !ShowMeterGroup and !HideMeterGroup. So a !Redraw tested and is working in every case (unless there is a hidden loophole somehow :lol: )
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7211
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by Yincognito »

CodeCode wrote: October 15th, 2023, 11:19 am I went with !ShowMeterGroup and !HideMeterGroup. So a !Redraw tested and is working in every case (unless there is a hidden loophole somehow :lol: )
Yes, in those cases, a redraw is enough, since setting an option (or variable, for that matter) isn't involved. :thumbup:
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
CodeCode
Posts: 1367
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by CodeCode »

Yincognito wrote: October 15th, 2023, 11:26 am Yes, in those cases, a redraw is enough, since setting an option (or variable, for that matter) isn't involved. :thumbup:
Well, to be fair I misexplained the code I used.

I used !SetOptionGroup!Redraw for everything.

But it is always good to hear that in any such case that might ever exist, there are two options to try.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
Yincognito
Rainmeter Sage
Posts: 7211
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by Yincognito »

CodeCode wrote: October 15th, 2023, 10:10 am my versions/permutations were also around 16 ifconditions
For the record, depending on what exactly you want to do in each case, I believe this can be achieved without any IfCondition and without going through each combination, just a single OnUpdateAction / OnChangeAction (the latter might require a proper value for the Formula in the measure) and some suited numeric conditionals, e.g.:

OnUpdateAction=[!SetOptionGroup AUL Hidden ((#2L#=50)||(#2T#=50)?0:1)]...

or even placing a dynamic Hidden (option or style) in the corresponding meters. Obviously, if clarity is desired, the approach laid out by balala is definitely the recommended one. The above would be suited if a shorter code is desired instead.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 7211
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Trying to decide - if rainmeter can toggle between 8 interrelated states of on or off, or to knock some lua into the

Post by Yincognito »

CodeCode wrote: October 15th, 2023, 12:19 pm Well, to be fair I misexplained the code I used.

I used !SetOptionGroup!Redraw for everything.

But it is always good to hear that in any such case that might ever exist, there are two options to try.
Without updating the relevant meters / group before redrawing, the set option approach you mentioned will not apply changes immediately. Just so you know and avoid other surprises / follow up questions later on... :confused:

Example:

Code: Select all

[Rainmeter]
Update=5000
AccurateText=1
DynamicWindowSize=1

---Meters---

[ImageOne]
Meter=Image
X=0
Y=0
W=100
H=100
SolidColor=255,0,0,255
LeftMouseUpAction=[!SetOptionGroup TargetGroup Hidden 1][!Redraw]
DynamicVariables=1

[ImageTwo]
Group=TargetGroup
Meter=Image
X=200
Y=200
W=100
H=100
SolidColor=0,255,0,255
DynamicVariables=1
For the code above, made according to your / balala's approach, you'll have to wait until the remaining time up to the 5 seconds skin update (or whatever update divider you set on the target meters) has passed before seeing the TargetGroup (i.e. ImageTwo) being hidden.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth