If your willing to make changes, I recommend using Vector3 with a 1D Dictionary to simulate a 3D array. Else, skip to the bottom on how to fix your issue.
var dict = {}
var first = Vector3(0,0,0)
dict[first] = whatever
var second = Vector3(2,43,1)
dict[second] = whatever2
I would rewrite your grid so that it is easier to use
var grid = {}
func get_item(x,y,z):
var index = Vector3(x,y,z)
if index in grid:
return grid[ index ]
return null #or whatever you want
func set_item(x,y,z, data):
var index = Vector3(x,y,z)
grid[ index ] = data
func fill_gird(max_x, max_y, max_z, filler = null):
#loop for x
#loop for y
for z in range(0, max_z): #loop for z
var index = Vector3(x,y,z)
grid[index] = filler
How to fix:
for x in range(grid_size.x):
target_grid.append([])
grid.append([])
for y in range(grid_size.y):
target_grid[x].append([])
grid[x].append([])
for _z in range(grid_size.z):
target_grid[x][y].append(null)
grid[x][y].append(null)
Access target grid using grid[x][y][z].