obj
buttons
Save
name="Save/Load"
screen_loc="1,4"
Click()
switch(alert("Would you like so save or load a level?","Save/Load","Save","Load","Cancel"))
if("Save")
var/Sav=input("What would you like to call your level?","Save",usr.lastsaved)as text|null
if(Sav)
var/savefile/F=new("Levels.sav")
F[Sav]<<GetCode()
usr.lastsaved=Sav
usr.levels+="[Sav]"
//for(var/whatever in usr.levels)world<<"[whatever]" <- Nothing is output here!
if("Load")
var/savefile/F=new("Levels.sav")
var/loading=input("Choose a level to load.","Loading")as null|anything in usr.levels
if(loading)LoadCode(F[loading])
I wasn't sure if this was a how-to or a problem, but I'm going to assume that the above code is horrible and wrong (Like always). Anyway, just about the last thing I gotta do before I've finished my game :) is to make a way of saving and loading levels. I thought I could save all a person's levels in one file called Levels.sav, and for every level a person has, there will be a variable in there with that level's name. Thanks to the way I've designed my game, levels can be encrypted into long strings of numbers, so that's not a problem.
The problem is that this doesn't work. After I tried some tests on this piece of code to find out which bits worked... I discovered that nothing seems to be getting added to usr.levels- at least, nothing outputtable. Does anyone have any idea what I'm doing wrong?