0 votes

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

edit: and how to work with these arrays.

in Engine by (330 points)
edited by

I would recommend you to Use Singletons

1 Answer

+3 votes
Best answer

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

by (834 points)
selected by

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

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
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.