Why does the dynamic allocation of gdscript not work in my case? (dictionary)

Godot Version

4.6

Question

Hi, why does the following not work?
for x in 100:
for y in 64:
for z in 64:
main_dic[x][y][z] = something1

it should create a main_dic[0], then a main_dic[0][0], then a main_dic[0][0][0] and put something1 in it, does it not?
Any help appreciated!

No, that doesn’t work. You need to create the dictionaries. This works:

	var main_dic: Dictionary
	for x in 3:
		main_dic[x] = {}
		for y in 3:
			main_dic[x][y] = {}
			for z in 3:
				main_dic[x][y][z] = 1

nvm, i figured it out, you need to tell the script each level is a dictionary…