[Features] Global variables

I would like to make a request, which maybe can help and improve the GD dynamics.

1 - A quick button for global variables: It would be nice to have a button above the code for quick access, as well as the Objects and Groups buttons.

2 - When adding a javascript, in GD, it could also be possible to create global variables (I couldn’t find anything like that from the command line), forgive me if this already exists. (It would be interesting to create global variables this way, because it’s easier to organize and can be left in external events, along with the code that uses them!)

3 - The screen of global variables should be the same as the one in Behavior, being able, however, to retract when it is a structure, and move, so we could better organize the variables in case you add or exclude any. However If it were possible to create the variables by command line, this part would not make sense, but it is a good idea!

From memory

runtimeScene.getGame().getVariables().add("variableName",999); // 999 can be string or boolean

runtimeScene.getGame().getVariables().get("variableName");

I’m pretty sure you don’t need the add step, you can get it directly and it will create it if missing.

1 Like

Yes we can, I was trying make it simple, step by step for non experimented users with the API.

I was realizing this yesterday, I was creating some object variables without having the variables declared, and they really work.