ID:179087
 
Has anyone successfully used multi-dimensional associative lists? I wanted to use text strings (colors) for the first dimension:

list/list[][] = new

If you add an obj to the "red" group:
list["red"] += obj

then reference it later by list["red"][1]

and then be able to loop on all "red" items in list:
for(list["red"])


I know this syntax at least is wrong, as I got a run-time error trying to access the list this way. Has anyone done something like this?

Thanks.
I've done nothing near that syntax, but I have done associative lists of associative lists. My first project, which I abandoned (maybe I'll pick it up again in a different form) used lists for that kind of purpose.

I don't think there's a direct syntax in BYOND capable of this, so you have to take kind of a long route.
var/list/l
var/list/l2
l2=list("three"=3,"four"=4)
l["one"]=l2
l2=list("five"=5,"six"=6)
l["two"]=l2

...
l2=l["one"]
var/n=l2["three"]
world << n

That should output 3.

Lummox JR