ID:272727
 
Okay for the first time in my BYOND programming...(I wanna say career lol) life, I'm dabbling in associative lists. :)

Here's my question. Do global lists save along with the world? If not, how would I get it save and load with the world? I have it where upon character load, their key is checked to see if it is in the associative, and if it is, give them a set of verbs.

var/Kages[] = list("Hokage"="<i>none</i>") //of course I have more entries, but we don't need to look at them all x.x

mob/Player
Owner/verb/Define_Hokage()
Kages["Hokage"] = usr
Login()
..()
if(src.key in Kages[src.key])
src.verbs += typesof(/mob/Player/Kages/verb)


However whenever I save and reload the world, the list is reset :\ Do I need to save the list to a savefile that's loaded everytime the world is?
Mizukouken Ketsu wrote:
Do I need to save the list to a savefile that's loaded everytime the world is?

Yes.
In response to Andre-g1
I'm afraid I don't know how to save a list to a savefile >.<
In response to Mizukouken Ketsu
Same way you save normal variables.
In response to Andre-g1
Normal vars save along with the Write() proc automatically. >_>

<s>Since my associative list is global, how would I make a savefile of it that would be loaded when the world is?</s>

EDIT
Nevermind, I figured it out :)
In response to Mizukouken Ketsu
Mizukouken Ketsu wrote:
Nevermind, I figured it out :)

In which case you should always include the solution for the (rare) case that someone (actually bothers to) use the forum search feature before posting a problem.
In response to Schnitzelnagler
var/list/ImportantPeople = list("Position1"="","Position2"="")

proc
List_Save()
var/savefile/L = new("Lists.sav")
L["ImprtntPpl"] << ImportantPeople
List_Load()
var/savefile/L = new("Lists.sav")
L["ImprtntPpl"] >> ImportantPeople

world/New()
..()
if(fexists("Lists.sav")) List_Load()

mob/proc/Make_Important(mob/M in world)
switch(alert("Which position?","Poition","Position 1","Position 2"))
if("Position 1")
ImportantPeople["Position1"] = M
List_Save()
if("Position 2")
ImportantPeople["Position2"] = M
List_Save()


Something along those lines...