[Solved] Set global variable with javascript?

Hi!

Set value of global variable:
runtimeScene.getGame().getVariables().get(“globalVarName”).setNumber(100);
runtimeScene.getGame().getVariables().get(“globalVarName”).setString(“new text”);

Get value of global variable:
var globalVarNumber = runtimeScene.getGame().getVariables().get(“globalVarName”).getAsNumber();
var globalVarString = runtimeScene.getGame().getVariables().get(“globalVarName”).getAsString();
5 Likes