How to create global array

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sprowk
:warning: Old Version Published before Godot 3 was released.

tried Globals.set(“name”,value) but cant figure out how to do this with array.

edit: and how to work with these arrays.

I would recommend you to Use Singletons

wf192 | 2016-10-25 03:49

:bust_in_silhouette: Reply From: GlaDOSik

How about Globals.set("name", [])? Anyway, I’m not sure Globals are for global properties. A good practice is to use autoload.

what if i want to change only 1cell of this array?
im new to godot but in python you just array[number] = something
Globals.set() just for 1cell doesnt make sense to me

Sprowk | 2016-10-24 16:19

Create, fill and set the array:

Globals.set("arrayName", [1, "whatever", 3.0])

Create and set empty array:

Globals.set("arrayName", [])

Add something to already created array in Globals:

Globals.get("arrayName").append(1)

Change first value in array:

Globals.get("arrayName")[0] = 5

GlaDOSik | 2016-10-24 16:32