It is currently April 27th, 2024, 6:18 am

Conditioning in Rainmeter is ambiguous...

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Conditioning in Rainmeter is ambiguous...

Post by Yincognito »

Engelard wrote: January 31st, 2024, 5:23 pm After four hours of struggling to implement my first(and only necessary) feature which involves some IF's - i have to admit that i failed.

Tell me please why my simple toggle do not working:

Code: Select all

[Variables]
KeyToFront = 0x83
Zval = -2


[Launcher2]
Measure=Plugin
Plugin=HotKey
HotKey=#KeyToFront#
DynamicVariables=1

IfCondition=Zval = 2
IfTrueAction=[!SetVariable Zval "-2"]
IfFalseAction=[!SetVariable Zval "2"]

KeyDownAction=[!ZPos #Zval#][!Redraw]
I mean it works sometimes if swap things around, but only for first keypress, and then it stays even if i refresh skin. This is all so confusing and unintuitive for newbies...
Yet another possibility...

In this code, if all you want is toggling between 2 and -2 for ZVal and the ZPos based on it, you don't even need IfConditions or setting UpdateDivider=-1, you could just do things directly in the KeyDownAction:

Code: Select all

KeyDownAction=[!SetVariable ZVal (-#ZVal)][!ZPos [#ZVal]][!Update]
Because of how the !Update bang works though, this will not update the measures or meters that have an UpdateDivider set on them with the new value of ZVal. If you need that as well, replace [!Update] above with [!UpdateMeasure *][!UpdateMeter *][!Redraw]. The * means "all of the same kind", by the way. Obviously, if you only use ZVal in the Launcher2 measure, [!UpdateMeasure Launcher2][!Redraw] would be enough. It all depends on what is sufficient for your needs.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Engelard
Posts: 5
Joined: January 31st, 2024, 5:12 pm

Re: Conditioning in Rainmeter is ambiguous...

Post by Engelard »

eclectic-tech and balala approach worked just well, thanks. It all was so difficult because i have poor conceptual understanding of this .ini meter-scripting technology. Feels way more difficult to comprehend after years making stuff with general-purpose languages C++/C#/Python etc...

But Yincognito clever solution with single line won this all. Fits exactly my purpose.
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Conditioning in Rainmeter is ambiguous...

Post by balala »

Engelard wrote: February 1st, 2024, 9:20 am eclectic-tech and balala approach worked just well, thanks. It all was so difficult because i have poor conceptual understanding of this .ini meter-scripting technology. Feels way more difficult to comprehend after years making stuff with general-purpose languages C++/C#/Python etc...

But Yincognito clever solution with single line won this all. Fits exactly my purpose.
Glad you got it working. At first, I personally didn't really understand what did you want to achieve, it started to be clear just after reding eclectic-tech's and Yincognito's replies. But definitely am glad you found the solution...
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Conditioning in Rainmeter is ambiguous...

Post by Yincognito »

Engelard wrote: February 1st, 2024, 9:20 am eclectic-tech and balala approach worked just well, thanks. It all was so difficult because i have poor conceptual understanding of this .ini meter-scripting technology. Feels way more difficult to comprehend after years making stuff with general-purpose languages C++/C#/Python etc...

But Yincognito clever solution with single line won this all. Fits exactly my purpose.
Excellent news! It doesn't really matter which solution you choose, as long as it does the job, but yeah, sometimes some are shorter than others, like in this particular case.

As for the Rainmeter .ini structure and syntax, it might help if you think of measures as "functions" that provide data (either internally or through a plugin), and of meters as visual "elements" that display data (either freely or through "associating" them with corresponding measures or variables). Both measures and meters can have event driven "actions" added to them depending on their type / kind (e.g. IfConditions, on update, on change, mouse actions, etc.), and can be changed or manipulated in various ways through "commands" called bangs or through specific "lines" / "options" like Substitute and others. It's a relatively simple structure/ syntax that can do most of what scripts written in other languages do, not to mention being able to use such scripts as well through specific plugin measures (like RunCommand).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth