ARRAY PROBLEM

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Potato_Boy_34

In GameMaker, I did this

for (i = 0; i < 1000; i += 1) {
global.variable_name[i] = false
}

Now I need to know how to do this in Godot.

:bust_in_silhouette: Reply From: deaton64

Hello,

Create a file called Global.gd
Add this to it:

extends Node

var variable_name = []

func _ready() -> void:
	variable_name.resize(1000)

In the menu under Project/Project Settings/Autoload click on the folder and add the file you created. It’s name should be Global and Global Variable should be Enabled.

You can access the array from your code like this:

for i in range(0,999):
	Global.variable_name[i] = false

You can put other variables and functions in the the Global.gd file and call them from anywhere.