[Solved] Concatenate Global Variable with Function Parameter


#1

Hey,

My goal is to test a global variable condition, but only testing the “parameter” condition.
I have multiple “progress.checkpointX” global variable, X being the parameter, and I was wondering if it would be possible (without javascript) to achieve this.

As far as I know, the “Variable” field does not accept text manipulation.

Thanks in advance !


#2

I’ve found a solution ! Hope it can help !

In the function documentation (http://wiki.compilgames.net/doku.php/gdevelop5/all-features/variables)
it’s said that we can access a “child” of a “main” variable, with the format : mainVariable[“childVariable”].

So, to dynamically change a global variable based on a function parameter, we just need to call the variable with this format :
mainVariable[“childVariable”+GetArgumentAsString(“NameOfParameter”)]

:slight_smile: