Connexion rapide:  

Forum: General Discussion

Sujet Button color depending on variable
bibi-bPRO InfinityMember since 2022
Hi there,

I would like to have a custom pad in the color of a given variable. For test purposes I have 2 buttons changing the variable:
button 1 action is -> set_var '$colorfx' red
button 2 action is -> set_var '$colorfx' green

The question is now how to script the color for the pad. I tried this e.g.:
color `get_var '$colorfx'`
or
color "`get_var '$colorfx'`"

But had no luck.

Can you help me with that?


 

Posté Wed 30 Nov 22 @ 4:32 pm
locoDogPRO InfinityModeratorMember since 2013
colors don't accept actions as a parameter, so what can you want to do is query the var against a string, if true then you know what color you want to call, if false try another color to query
something like this

param_equal `get_var $colorfx` "red" ? color red : param_equal `get_var $colorfx` "green" ? color green : 



*Edit*, actually I was wrong, [maybe not wrong but there's an easier way]
you can do this

get_var $colorfx & param_cast 'text' & color
 

Posté Wed 30 Nov 22 @ 5:02 pm
bibi-bPRO InfinityMember since 2022
Perfect! Thanks a lot.
 

Posté Wed 30 Nov 22 @ 8:38 pm
bibi-bPRO InfinityMember since 2022
One more question: How is the second code if I want the color e.g 50%

Thanks!
 

Posté Thu 01 Dec 22 @ 1:38 pm
locoDogPRO InfinityModeratorMember since 2013
I think you're out of luck with that, you can only cast one thing at a time, simple color name & brightness are 2 things.

I suppose you could use RGB to make it one thing.
 

Posté Thu 01 Dec 22 @ 1:57 pm
bibi-bPRO InfinityMember since 2022
merci!
 

Posté Thu 01 Dec 22 @ 2:18 pm