How do I use getVariableNumber?


#1

I’d like to use getVariableNumber, not using getVariables.get(‘name’).getAsNumber();
But I don’t know how to do it.


#2

Javascript programming has strict rules, it’s not possible to do as we imagine.

The good method is to use a variable like you do at line 1,2 and 3.
You can reduce runtimeScene.getVariables() in a variable too.
Like

let sceneVariables = runtimeScene.getVariables();


#3

The good method is indeed to use getAsNumber(); and as Bouh said you can keep a reference on the scene variable to reduce the line lengths.

Any other method is not officially supported and will break your game in a future version of GDevelop if you use it - stick with getAsNumber() :slight_smile: