It is currently April 18th, 2024, 5:39 pm

Missing a cycle update...

Get help with creating, editing & fixing problems with skins
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Missing a cycle update...

Post by brax64 »

Hi all,

this code is working ALMOST as intended...

Code: Select all

[MeterBG]
Meter=Image
X=0
Y=0
H=(#LineH# +[Meterline50:Y])
W=(#LineW# + #XPos#*(#Bands#-1))
SolidColor=0,0,0,1
UpdateDivider=-1
LeftMouseUpAction=["#@#\AudioVariables.inc"]
MouseScrollDownAction=[!SetVariable "Sensitivity" "(#Sensitivity# - 5)"][!WriteKeyValue Variables Sensitivity #Sensitivity# "#@#AudioVariables.inc"][!UpdateMeter MeterBG]
MouseScrollUpAction=[!SetVariable "Sensitivity" "(#Sensitivity# + 5)"][!WriteKeyValue Variables Sensitivity #Sensitivity# "#@#AudioVariables.inc"][!UpdateMeter MeterBG]
MouseOverAction=[!ShowMeter SensitivityDisplay]
MouseLeaveAction=[!HideMeter SensitivityDisplay]
DynamicVariables=1
ToolTipText=ScrollWheel to increase/decrease Sensitivity#CRLF#LeftClick to edit AudioVariables

[SensitivityDisplay]
Meter=String
Text=Sensitivity: #Sensitivity#
X=0
Y=(#LineH# + [Meterline50:Y] - 10)
Fontface=#ff#
Fontsize=8
FontColor=255,160,0,180
DynamicVariables=1
Hidden=1
AntiAlias=1
The only imperfection I have is that the variable #Sensitivity# is always lagging by 5; I see with the meter that it's value change on the fly (aka every wheel scroll action) but always one scroll later inside the AudioVariables.inc file, thus lagging 5.
What am I missing?
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Missing a cycle update...

Post by mak_kawa »

Hi brax64

I am not fully sure about variable update timing, but what if you change order of two bangs? Like as;

Code: Select all

MouseScrollDownAction=[!WriteKeyValue Variables Sensitivity "(#Sensitivity# - 5)" "#@#AudioVariables.inc"][!SetVariable "Sensitivity" "(#Sensitivity# - 5)"][!UpdateMeter MeterBG]
MouseScrollUpAction=[!WriteKeyValue Variables Sensitivity "(#Sensitivity# + 5)" "#@#AudioVariables.inc"][!SetVariable "Sensitivity" "(#Sensitivity# + 5)"][!UpdateMeter MeterBG]
As always, sorry if I am misunderstanding.
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Missing a cycle update...

Post by brax64 »

mak_kawa wrote: September 20th, 2020, 11:40 pm Hi brax64

I am not fully sure about variable update timing
...

As always, sorry if I am misunderstanding.
Hi mak_kawa

Thanks for your quick reply, well your trick it's actually working, but I'm not understanding the logic...
I'm surely missing something about the whole mechanic behind the scene on how/when Rainmeter is doing its thing...
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Missing a cycle update...

Post by mak_kawa »

Hi brax64

I too am not sure why that trick does work... :-) Probably only the developers of Rainmeter can explain.

Just my guess, don't believe... :-) We ordinary expect following bangs work as; "#SomeVar# is updated -> the updated #SomeVar# value is written".

Code: Select all

[!SetVariable SomeVar (Some modify to #SomeVar#)][!WriteKeyValue Variables SomeVar #SomeVar#]
But sometimes (always? I am not sure) they work as; "#SomeVar# is updated & #SomeVar# value before update is written".

So, as an workaround, I set these bangs as follows;

Code: Select all

[!WriteKeyValue Variables SomeVar (Some modify to #SomeVar#)][!SetVariable SomeVar (Some modify to #SomeVar#)]
Again I am not sure why these bangs don't work as; "#SomeVar# is updated -> the updated value for already updated #SomeVar# value is written", :-) if the description order of bangs doesn't matter.
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Missing a cycle update...

Post by brax64 »

mak_kawa wrote: September 21st, 2020, 12:09 am Hi brax64

I too am not sure why that trick does work... :-) Probably only the developers of Rainmeter can explain.

Just my guess, don't believe... :-) We ordinary expect following bangs work as; "#SomeVar# is updated -> the updated #SomeVar# value is written".

Code: Select all

[!SetVariable SomeVar (Some modify to #SomeVar#)][!WriteKeyValue Variables SomeVar #SomeVar#]
But sometimes (always? I am not sure) they work as; "#SomeVar# is updated & #SomeVar# value before update is written".

So, as an workaround, I set these bangs as follows;

Code: Select all

[!WriteKeyValue Variables SomeVar (Some modify to #SomeVar#)][!SetVariable SomeVar (Some modify to #SomeVar#)]
Again I am not sure why these bangs don't work as; "#SomeVar# is updated -> the updated value for already updated #SomeVar# value is written", :-) if the description order of bangs doesn't matter.
You're on point, that's exactly what I meant with "I don't understand the logic" in my answer...
Hope that some sage/developer can shed some light about this!
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Missing a cycle update...

Post by jsmorley »

All variables are resolved when the entire action is read on each update. You can't change the value of a variable and use the new value in the same action.

The bangs you put in any given action do happen in "order", but all within the same update cycle. One way to look at it is that they all happen "at once". They don't actually, but really in a sense they might as well.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Missing a cycle update...

Post by mak_kawa »

Hi jsmorley

Thank you for clarification. I've maybe heard it from you in some thread... sorry for my amnesia. :-)
Bangs in one action are executed "at once"... I will never forget it, I wish.
User avatar
Brian
Developer
Posts: 2678
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Missing a cycle update...

Post by Brian »

jsmorley wrote: September 21st, 2020, 2:26 am All variables are resolved when the entire action is read on each update. You can't change the value of a variable and use the new value in the same action.

The bangs you put in any given action do happen in "order", but all within the same update cycle. One way to look at it is that they all happen "at once". They don't actually, but really in a sense they might as well.
I just wanted to clarify one small thing with this. A regular #variable# will only be resolved when the action is resolved (during the update cycle).....however, using nested syntax [#variable], you can set a variable and use the new value later with another bang within the same action.

Example:

Code: Select all

[Variables]
Var=1

[Meter]
Meter=String
Text=Click Me
SolidColor=0,0,0
FontColor=255,255,255
LeftMouseUpAction=[!About][!Log [#Var]][!SetVariable Var 2][!Log [#Var]]
See the Notes under the "The alternative Nesting Variables syntax" section at the top.
https://docs.rainmeter.net/manual/variables/nesting-variables/

-Brian
User avatar
brax64
Posts: 172
Joined: July 8th, 2018, 8:05 pm

Re: Missing a cycle update...

Post by brax64 »

Brian wrote: September 21st, 2020, 4:51 am I just wanted to clarify one small thing with this. A regular #variable# will only be resolved when the action is resolved (during the update cycle).....however, using nested syntax [#variable], you can set a variable and use the new value later with another bang within the same action.

Example:

Code: Select all

[Variables]
Var=1

[Meter]
Meter=String
Text=Click Me
SolidColor=0,0,0
FontColor=255,255,255
LeftMouseUpAction=[!About][!Log [#Var]][!SetVariable Var 2][!Log [#Var]]
See the Notes under the "The alternative Nesting Variables syntax" section at the top.
https://docs.rainmeter.net/manual/variables/nesting-variables/

-Brian
Hi Brian,
Thank you very much for this clarification, actually in the specific application as per my OP, your proposed format is working!

Code: Select all

MouseScrollDownAction=[!SetVariable Sensitivity "([#Sensitivity] - 5)"][!WriteKeyValue Variables Sensitivity [#Sensitivity] "#@#AudioVariables.inc"][!UpdateMeter MeterBG]
MouseScrollUpAction=[!SetVariable Sensitivity "([#Sensitivity] + 5)"][!WriteKeyValue Variables Sensitivity [#Sensitivity] "#@#AudioVariables.inc"][!UpdateMeter MeterBG]
Also thanks to jsmorley for his patience with all of us asking million times the same questions !!! :D :rosegift:
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Missing a cycle update...

Post by jsmorley »

Brian wrote: September 21st, 2020, 4:51 am I just wanted to clarify one small thing with this. A regular #variable# will only be resolved when the action is resolved (during the update cycle).....however, using nested syntax [#variable], you can set a variable and use the new value later with another bang within the same action.

Example:

Code: Select all

[Variables]
Var=1

[Meter]
Meter=String
Text=Click Me
SolidColor=0,0,0
FontColor=255,255,255
LeftMouseUpAction=[!About][!Log [#Var]][!SetVariable Var 2][!Log [#Var]]
See the Notes under the "The alternative Nesting Variables syntax" section at the top.
https://docs.rainmeter.net/manual/variables/nesting-variables/

-Brian
Interesting. I had never tumbled to the implications of that in this context.

LeftMouseUpAction=[!About][!Log [#Var]][!SetVariable Var "([#Var]+1)"][!Log [#Var]]

Do keep in the back of your mind that using nested variables, while extremely useful, will cause just a hair more work by Rainmeter on each update. My advice is to use them where you need them, and use the old-style variables and section variables where they will do the trick. The additional hit is so small individually that it rounds to zero, but these things can add up in a large and complicated skin.