It is currently March 28th, 2024, 10:11 am

Help with variables and text

Get help with creating, editing & fixing problems with skins
Gouloudrouioul
Posts: 17
Joined: May 17th, 2020, 2:07 am

Help with variables and text

Post by Gouloudrouioul »

Hi !

So I'm stuck big time, and I don't know what the solution could be... I feel like I tried everything, and I can't see where the problem is.
So I created a variable that I want to increment.
Then I want a text to display my incremented variable on the screen.

The text part works fine when I don't increment anything and when I just change the variable. But when I try to add + 1 to my variable, it always shows 0... Here's my code :

Code: Select all

[Variables]
BgTransf=0

[MeasureTransformMBG]
Measure=Plugin
Plugin=ActionTimer
ActionList1=AddOne | Wait 1000 | UnveilDock
UnveilDock=[!SetOption MeterText1 Text #*BgTransf*#][!UpdateMeter MeterText1][!Redraw]
AddOne=[!SetVariable BgTransf (#BgTransf# + 1)]

[MeterText1]
Meter=String
X=0
Y=0
FontColor=197,239,252,255
FontSize=12
Text=test
DynamicVariables=1
I would be extremely grateful if you could tell me where I did wrong... :D
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

Code: Select all

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

[Variables]
BgTransf=0

[MeasureTransformMBG]
Measure=Plugin
Plugin=ActionTimer
ActionList1=AddOne | Wait 1000 | UnveilDock
UnveilDock=[!SetOption MeterText1 Text #*BgTransf*#][!UpdateMeter MeterText1][!Redraw]
AddOne=[!SetVariable BgTransf "(#BgTransf# + 1)"]
DynamicVariables=1

[MeterText1]
Meter=String
X=0
Y=0
FontColor=197,239,252,255
FontSize=12
Text=test
DynamicVariables=1
LeftMouseUpAction=[!CommandMeasure MeasureTransformMBG "Execute 1"]
So...

1) The parameter in the !SetVariable option has spaces in it, so it must be enclosed in "quotes".
2) You need DynamicVariables=1 on [MeasureTransformMBG], or it will never see the change to the variable.
3) You need something, somewhere that uses !CommandMeasure to fire off the ActionTimer measure.
Gouloudrouioul
Posts: 17
Joined: May 17th, 2020, 2:07 am

Re: Help with variables and text

Post by Gouloudrouioul »

Oh yes, I forgot to show that but it's there !

Wow, thanks a lot for your quick help, it was helpful ! :) Now the action works. But..... Only once. If I try to use repeat, to trigger it an other time, or anything else it doesn't work...

I seem to have missed something on how ActionTimers work ?

So here's my complete code :

Code: Select all

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

[Variables]
BgTransf=0

[MeterActionZone]
Meter=Image
X=0
Y=0
W=((#TotalIcons# * (#SpaceIcons# + #IconSize#)) - #SpaceIcons# + 20)
H=(#IconSize# + #SpaceLineIcons# + #LineThickness# +10)
SolidColor=0,0,0,1
MouseOverAction=[!CommandMeasure MeasureTransformMBG "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureTransformMBG "Stop 1"]
DynamicVariables=1

[MeasureTransformMBG]
Measure=Plugin
Plugin=ActionTimer

;Trying to trigger it multiple time with MouseOver, but failing
ActionList1=AddOne | Wait 300 | UnveilDock

;OR
;Trying to repeat the same action multiple time, but failing also D: 
;ActionList1=Repeat AddOne, 5, 5 | UnveilDock

UnveilDock=[!SetOption MeterText1 Text #*BgTransf*#][!UpdateMeter MeterText1][!Redraw]
AddOne=[!SetVariable BgTransf "(#BgTransf#+1)"]
DynamicVariables=1

[MeterText1]
Meter=String
X=0
Y=0
FontColor=197,239,252,255
FontSize=12
Text=test
DynamicVariables=1
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

Works for me.

Code: Select all

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

[Variables]
BgTransf=0

[MeterActionZone]
Meter=Image
X=0
Y=0
W=50
H=50
;W=((#TotalIcons# * (#SpaceIcons# + #IconSize#)) - #SpaceIcons# + 20)
;H=(#IconSize# + #SpaceLineIcons# + #LineThickness# +10)
SolidColor=0,0,0,90
MouseOverAction=[!CommandMeasure MeasureTransformMBG "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureTransformMBG "Stop 1"]
DynamicVariables=1

[MeasureTransformMBG]
Measure=Plugin
Plugin=ActionTimer

;Trying to trigger it multiple time with MouseOver, but failing
ActionList1=AddOne | Wait 300 | UnveilDock

;OR
;Trying to repeat the same action multiple time, but failing also D: 
;ActionList1=Repeat AddOne, 5, 5 | UnveilDock

UnveilDock=[!SetOption MeterText1 Text #*BgTransf*#][!UpdateMeter MeterText1][!Redraw]
AddOne=[!SetVariable BgTransf "(#BgTransf#+1)"]
DynamicVariables=1

[MeterText1]
Meter=String
X=0
Y=0
FontColor=197,239,252,255
FontSize=12
Text=test
DynamicVariables=1

I had to fudge that [MeterActionZone] meter a bit, since I don't have all those variables that set the size, but once I have it so I can properly mouse over it, it will count up by one each time I do.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

I must say, I'm beginning to lose the logic of what you are trying to do.

If you just want to increment a number by 1 each time you mouse over it, you really don't need an ActionTimer for that, it's kinda overkill. If you are looking to have it increment 5 times when you mouse over, I'm not sure that makes a lot of sense either. Why not just increment it by 5, that is what you are going to end up with anyway...

I have a feeling that there is some bigger, far more complicated goal you are going for, but I'm not sure we are going to get there this way.
Gouloudrouioul
Posts: 17
Joined: May 17th, 2020, 2:07 am

Re: Help with variables and text

Post by Gouloudrouioul »

Hmmm that's strange... It must be caused by some other chunk of code then I guess... I'll check that tomorrow

However I can't seem to make the "Repeat" part work. It only adds 1, and not 1 x 5... Is that how it's supposed to work ?

I want it to repeat the "AddOne" action five times, then to display it. But it doesn't do that :confused:

Thanks for answering so quick :D
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

I have a feeling I don't want your entire skin, as I'm guessing it's a gigantic, complex thing that I am just going to glaze over and start drooling when I look at it.

What might help though, is to express, just in words, what effect and intent you are going for.
Gouloudrouioul
Posts: 17
Joined: May 17th, 2020, 2:07 am

Re: Help with variables and text

Post by Gouloudrouioul »

Well... I'm actually trying to make sense of how this ActionTimer work before continuing my big plans :D
I need to understand the logic behind it before continuing (and because it makes me mad not to understand it, so I'm doing some tests)

But I wanted to do that first because it seemed to me like it was the only way to animate an image.
I want to make an image appear by being flat at first, then by growing bigger and bigger.

Do you think there is simpler solution than ActionTimer to do that ?

(sorry for my english, not native)

EDIT for your last post : Ahah yeah, I guarantee you don't want to make sense of my entire skin :D
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

Take a look at this:

Code: Select all

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

[Variables]
MyVariable=0

[MeterBack]
Meter=Image
W=50
H=16
SolidColor=255,0,0,90
MouseOverAction=[!SetOption MeterText1 Text #*MyVariable*#][!CommandMeasure MeasureCounter "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureCounter "Stop 1"]
DynamicVariables=1

[MeasureCounter]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat AddOne, 1000, 5
AddOne=[!SetVariable MyVariable "(#MyVariable#+1)"][!UpdateMeasure MeasureCounter][!UpdateMeter MeterText1][!Redraw]
DynamicVariables=1

[MeterText1]
Meter=String
X=0
Y=0
FontColor=197,239,252,255
FontSize=12
Text=test
DynamicVariables=1
The way ActionTimer works with "Repeat" is that it will execute the named option, AddOne in this case, and then wait for some amount of time, 1000 milliseconds in this case, and then do that some number of times, 5 in this case.

When this "Repeat" is going on, you MUST !UpdateMeasure the ActionTimer measure between each repeat, so it can update the current value of the #Variable# you are changing. And you must update the meter(s) and redraw, so so actually see the changes as they happen. That is why I have:

[!UpdateMeasure MeasureCounter][!UpdateMeter MeterText1][!Redraw]

At the end of the AddOne option.

Let me know if this helps, or if you have further questions.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

This is a good approach for zooming an image in and out. You are on the right track.
Post Reply