Simplify multiple adanced actions with JavaScript ?
...
Hello Captivaters !...
I'm working on a project where visitors have to reproduce figures...
This is what it looks like :

As you can understand it easily, first the learner has to select a color. And then click on a triangle to change its color with the selected one...
All the white triangles are in fact buttons with 5 differents states (normal is white, then there is a Green, Red, Yellow and Blue state)...
I created a variable "v_Color". And by clicking on the colored button on top of the image, I assign a name to this variable (Green, Red, Yellow or Blue).
So for example if my first white button triangle is named "T_01" when I click on it I play an advanced conditional action with 4 conditions :
If "v_Color" is equal to "Green"
=> Modify the state of "T_01" to "Green"
If "v_Color" is equal to "Red"
=> Modify the state of "T_01" to "Red"
If "v_Color" is equal to "Green"
=> Modify the state of "T_01" to "Yellow"
If "v_Color" is equal to "Red"
=> Modify the state of "T_01" to "Blue"
And everything is perfect !...
But as you can see, there are many triangles !!!... And I have to change the action on each one... That means a lot of actions !...
So I'm sure it's possible to simplify this with only one javascript action like :
=> Clicking on "this" (instead of the name of the button)
If "v_Color" is equal to "Green"
=> Modify the state of "this" to "Green"
If "v_Color" is equal to "Red"
=> Modify the state of "this" to "Red"
...
So only one action will be performed for each button/triangle...
I need your help to code this "this"... !!!...
Thanks in advance !...
😉
...
