Write to a string/global variable

My idea is quite simple: Add a Kustom Action that allows a change to a global text variable.

An example of where this could be useful is when defining "States" that require more than 2 options

i.e.

Background 1:
- Shape
- Touch Action - Write To Global - 1
- $if(gv(state) = 1, Show, Hide)$

Background 2:
- Shape
- Touch Action - Write To Global - 2
- $if(gv(state) = 2, Show, Hide)$

Background 3:
- Shape
- Touch Action - Write To Global - 3
- $if(gv(state) = 3, Show, Hide)$

Hi! You can do this already, actually in your specific case you can do this in 2 ways. Lets go through both.

Text Global

Lets say you want to just increment a counter always by one

  • Add a global of type Text and call it "counter"
  • Write "0" as value
  • Add a Shape, set touch action to "Switch Global"
  • Select the counter global
  • In the formula section write $gv(global)+1$

Done, your counter global will be incremented by one at each touch

List Global

If you want to cycle between a set of values (like 1,2,3) in your example you can do this:

  • Add a global of type List and call it "values"
  • Write "1,2,3" as values
  • Add a Shape, set touch action to "Switch Global"
  • Select the "values" global
  • Select "Go To Next" as action

Done, your global will go from 1 to 3 and back

Wow, thank you! This will certainly come in handy!

ok however it would be much more useful to be able to directly modify the variable from code. for example: in a loop cycle, being able to perform calculations and then subsequently save them in a variable for later use. as it is now the variable can be practically changed only with a direct interaction from the user, which is not exactly the best

"In the formula section write $gv(global)+1$"

Doesn't work for me. The counter variable is named "counter" as per your first step, so the formula should be $gv(counter)+1$.