I have a button that increases a global variable by 1, this is used for a character select menu. Obviously, I dont have infinite characters to select but I dont currently have a maximum as I'm still working on it. Is there an expression I can use that makes the number roll back to the lowest value after it hits the top value?
System > compare two values > global variable counter is greater than global variable max > action : set global variable counter to 0 (or min)
Develop games in your browser. Powerful, performant & highly capable.
You can also use ternary operator. Say, to increase the number up to 10, then reset to 0:
Set var to (var<10 ? var+1 : 0)
My favourite approach for resetting value would be using modulo:
Set value to (var+1)%maxValue
, you just need to replace maxValue with number or a defined variable.