It is currently March 29th, 2020, 12:05 am

Switch between two variables in bangs

Help with creating, editing & fixing problems with skins
marvil6
Posts: 1
Joined: March 26th, 2020, 9:27 pm

Switch between two variables in bangs

Post by marvil6 »

Hi! I'm making basic musicplayer a skin, but since i use spotify, rainmeter doesn't know if it's playing or not. I'm trying to make the button switch between a pause and play texture, but i dont know how to switchthe variable. Is there a way to make !SetVariable check first before setting it?

tl;dr i need help making a bang do "if var = 0, set var to 1. if var = 1, set var to 0," thank you! :D
User avatar
DanDaBear
Posts: 29
Joined: February 23rd, 2018, 3:12 am

Re: Switch between two variables in bangs

Post by DanDaBear »

Depending on what you want the variable to start on, Make it's value the opposite. So if you wanted it to be 1:

Code: Select all

ToggleMe=0
Then toggle between 1 and zero with:

Code: Select all

LeftMouseDownAction=[!SetVariable ToggleMe (1-#ToggleMe#)]

Code: Select all

LeftMouseUpAction=[!Bang to play music]
You can name the variable whatever you want (within reason)
User avatar
balala
Rainmeter Sage
Posts: 10009
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Switch between two variables in bangs

Post by balala »

DanDaBear wrote:
March 26th, 2020, 9:53 pm
Then toggle between 1 and zero with:
Additionally note that you have to set on the dynamic variables on every measure or meter where you wanna use the dynamically set variable (in this case ToggleMe), by adding a DynamicVariables=1 option to that measure or meter. This has to be done even on the meter where the above LeftMouseDownAction is set on.
One more: not a too good idea to use LeftMouseDownAction on the meter, unless there is another reason to do this. I'd add both bangs to the LeftMouseUpAction.