It is currently April 19th, 2024, 7:34 am

Trying to get a mouse click to ping-pong a loop

Get help with creating, editing & fixing problems with skins
RichKat666
Posts: 10
Joined: January 3rd, 2020, 5:43 pm

Trying to get a mouse click to ping-pong a loop

Post by RichKat666 »

So I've got a loop which I want to go back and forth each time the mouse clicks on an object. So with every click, the InvertMeasure of the loop is changed, the loop is updated.

I have this code at the minute, and I have no idea why it isn't working

Code: Select all

[Rainmeter]
Update = 16
DynamicWindowSize = 1

[Variables]
InvertExpansion = 1

[ExpansionLoop]
Measure = Loop
StartValue = 0
EndValue = 100
Increment = 1
LoopCount = 1
InvertMeasure = #InvertExpansion#
UpdateDivider = 1
DynamicVariables = 1

[TempVar]
Measure = Calc
Formula = #InvertExpansion# = 1 ? 0 : 1
DynamicVariables = 1
UpdateDivider = -1

[CentreShape]
Meter = Shape
Shape = Rectangle (#WORKAREAWIDTH#/2), (#WORKAREAHEIGHT#/2), 24, 24 | Offset -12, -12

LeftMouseDownAction = [!UpdateMeasure TempVar][!SetVariable InvertExpansion TempVar][!UpdateMeasure [ExpansionLoop]]

DynamicVariables = 1

[UsefulText]
Meter = String
X = 500
Y = 400
FontSize = 20
Text = [ExpansionLoop]

DynamicVariables = 1

I've tried several things for just over an hour, and I'm lost. I would really love some suggestions.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trying to get a mouse click to ping-pong a loop

Post by balala »

RichKat666 wrote: January 14th, 2020, 6:07 pm I have this code at the minute, and I have no idea why it isn't working
Because there is a small mistake into the !SetVariable bang of the LeftMouseDownAction option of the [CentreShape] meter. As used, it sets the InvertExpansion variable not to the appropriate numeric value, but to the TempVar string itself, because in such cases the bang don't know you want to set the appropriate numeric value and TempVar is a string which is set to the variable. You have to use the name of the [TempVar] measure as a section variable, so modify the above option as it follows: LeftMouseDownAction=[!UpdateMeasure TempVar][!SetVariable InvertExpansion "[TempVar]"][!UpdateMeasure "ExpansionLoop"].
Also note that the brackets are not needed around the name of the [ExpansionLoop] measure in the !UpdateMeasure bang (fixed this as well).
RichKat666
Posts: 10
Joined: January 3rd, 2020, 5:43 pm

Re: Trying to get a mouse click to ping-pong a loop

Post by RichKat666 »

Thank you, I thought it might have been something like that :/
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trying to get a mouse click to ping-pong a loop

Post by balala »

RichKat666 wrote: January 14th, 2020, 6:28 pm Thank you, I thought it might have been something like that :/
Many times it is. Glad if fixed.