ID:155954
 
I don't know, it seems simple enough but apparently directly saving and loading lists not attached to atoms doesn't work as well as I think it should.

I wanted to be able to save and load a single list filled like this:

list_name["Oasiscircle"]="Gary"


Stuff like that, you know?
Strange, I think it works just fine. This is off the top of my head, so I'm not guaranteeing it works, or is the best way to do it.
proc/SaveList(list/L, savefile/file)
file << L

proc/LoadList(savefile/file)
file >> .

// A couple test verbs for you.
mob
verb
Save()
var L[] = list("A"=1, "B"=2, "C"=3)
var savefile/s = new("Test.list") // You can save savefiles with whatever extension you want.
SaveList(L, s)

Load()
var L[] = LoadList(new/savefile("Test.list"))
for(var/t in L)
src << "[t]: [L[t]]"

With this, you can save individual lists to their own savefile and load them.
In response to Kaiochao
But, now how am I supposed to add things to the list?
Whenever I do something like:

list_name["[var1]"]="[var2]"


it gives me an error message. How am I supposed to add entries? D:
In response to Oasiscircle
What error message are you getting?(that question's pretty cliche in these forums, by the way)
That's how I usually set associations to list indices. That's also how it's shown in the DM Reference under "list associations."

One possible error you could be getting is that the list isn't actually created by the time you're trying to add to it.
// All these create new empty lists.
var List[] = list()
var List[0]
var List[] = new
var list/List = new
var list/List[] = list()

// These may be what you're doing. Lists aren't actually created, only defined as lists.
var List[]
var list/List

// This gives a funny compile-time error.
var List[0] = list()
var list/List[0] = list()
In response to Kaiochao
Nevermind, I solved the problem. Thanks Kaiochao! (: