Do you literally want a n-dimensional array, or do you want an array that contains values or other arrays?
For an actual n-dimensional array you could use a 1d array to do it. The size would be width*height*depth*... and accessing would be:
And so on
You’d probably wrap that in a function and you could make it resizeable with a bunch of inserts/deletes to move stuff around.
For a 4d array you could also just use multiple instances of a 3D array and access it with array(x).at(y,z,w)
You’ll have to deal with new instance picking if you end up creating more instances, not to mention you’d be limited to adding to the end of one dimension.
The idea may be extendable for more dimensions. I like the uid idea too, but you’ll have to be more deliberate about setting it up.
Now the issue with n-dimetional arrays is the amount of memory really blows up the more dimensions you add. Which is why I asked if what you want is arrays that contain values or other arrays, each with their own size. Kind of like a file tree.
Anyways I’d imagine json might work for that. I don’t know if you can use it as a dynamic data structure or just to access the data since I haven’t used it.
You could also use a normal array to do the dynamic tree structure. Basically you’d store values in pairs: a type and a value. The type would be either be “value” or “array”, and the value would be anything or the uid of another array. You’d then just use a function to do the reading, writing and any sort of extending/resizing. I guess the main aggravation here are errors. Your lookup should be simple as function.call(“at”, arrayid, x, y, z, w) which would access access each parameter as an array index. The trouble is if it tries to access a value as an array. There you could put put an error, which may be hard to hunt down in events, or just output 0 like normal events do out of range.
If you ended up making a plugin you can detect where in the event sheet the calls are done, so that may help. There may. E a way to do it with the browser execjs action as well.
Anyways a few other ideas for you. Personally I’d go the event based route. It’s easier to maintain and update.