How I define a list within a list:
mob
var
list
item_list = list()
verb
define_list()
for(var/obj/o in contents)
if(!(o.name in item_list))
item_list[o.name] = list()
item_list[o.name] += o
The ONLY way that works to access it:
mob
verb
check_list_1()
for(var/i in item_list)
world<<i
for(var/n in item_list[i])
world << "found item in list"
A way that SHOULD work and I need it to:
mob
verb
check_list_2()
world << "found [item_list[1][1]]"
The reason why it isn't working as you expected is due to the following:
list[N] --> returns the o.name here (generally, returns the Nth entry in the /list)
list[N][M] --> Will return the Mth entry in a /list of the Nth element.
The above is assuming that M & N are numbers
If you enter the reference (or string in this case), it'll return its value:
list[o.name] --> returns the object that it has stored as its value
The point is, if you want to access the object with the system you have set up now, you need to do:
If you want it the [N][M] method, then change:
Summary:
/list = list(Entry = Value, "X" = Y)
list[Number] == returns the Entry value for that position in the list
list[Entry] == returns the value that has been set
list[list[Number]] == list[Entry]