Declaring global variable as an array and accesing instance variables through javascript

How does it work? I tried making a global variable an array by putting ‘[]’ around it but it doesn’t work.
I also can’t access instance variables by object.variableName or object.getVariables.get(“name”).
If global varibles can only be strings and numbers, what would be the correct approach to this problem: I want to let color blind players choose the color of certain objects. (I need a global list of all available colors for this)
Is it correct to change the color onLoad in the object’s behavior? I think if I do it in the scene events it will not show in the first frame.

To access scene variables use runtimeScene.getVariables().get(“variablename”) and then the method setString setNumber getAsNumber getAsString (names are selfexplaining) and for global variables runtimeScene.getGame().getVariables().get(“variable name”) and the same methods

Thanks but I meant instance variables. This will be usefull too for sure though.

Oh,ok. Do you mean for each object? You need to get an object then use his getVariables method etc like I said and to make an array in JavaScript you don’t make [] around a variable name. When you get an instance of an object you can add an attribute to it, like o.my_array = [].

I know how to declare an array, I just don’t know how to make it a global variable.
I am pretty sure I tried ‘getVariable.get(“name”)’ on an object already, like I said. Maybe I mistyped… I’ll try it again.

GDevelop Variables doesn’t work like that. You just need to create a Javascript variable as an object of window