ok, wondering if there was anyway at all to allow Godot to build multi-dimensional Arrays in a future build? I know how to use GDscript code to create one, but would be nice if it was built in.
You can already nest arrays ( Array[Array], or just [[1, 2], [3, 4]]). There’s no separate multi-dim array type though, and nested typed arrays like Array[Array[int]] aren’t supported yet as far as i know.
I effectively implement that when I need to via dictionary or nested array, though coming from a C background I too would like to see something like that.
You can write your own stride-based multidimensional array type. In the long term, that would be the best approach. Some significant up-front effort, but you get an actual multidimensional array, not a cheap imitation.
Failing that, an array of arrays or a dictionary with vectors as keys would also work.
If by extension, you would use it so: my_3d_array[0][0][0] = 12
Then this format would be a major breaking change since currently this is valid syntax.
var my_3d_array:Array = [[1,2,[3,4]]]
print(my_3d_array[0][2][0])
So you would need to find another syntax for it.
It is probably better to have separate variable type for it.
For myself I am doing a procedurally generated simulated environment in my 2D game. I might use them to store my x-component (where we are in the world), the thorn density, the mood, the light levels, the creature generation, the plant generation… anything and everything really. With a multi dimensional array I could do [chunk_position, magical intensity, corruption] but more importantly it would be easily reversible.
When I tried to do a 3D game of life, it would have been great for that too.
Yes, I am managing fine without it. But like the OP said, it would be nice if it was built in.
How handy would that be. My creature procedural generation would be a cinch with this especially varying it with time of day.
@japonbaligi
Thanks for those links. Support given!
to BABA, for everything that involves x , y and or z arrays. as in a table of X,Y,Z positions for 3D. lots of other uses for multi-dimensional arrays. most high level programming languages have multi-dimensional arrays. And its makes programming life better. Been programming since the mid 80s, used these kind of arrays a lot. and yes as stated, I can create my own , in code, by nesting arrays with-in arrays. but its a pain and be better if it were built-in . Thanks for your time. and happy coding.