ID:2424203
 
Code:
turf/var/gang_name=""
turf/houses
var/purchasing=0
House1
var/price=1000
HouseEnter
Enter(var/mob/player/M)
if(!M) return
if(src.gang_name==""||src.gang_name==null)
if(M.InGang)
switch(alert(M,"Do you wish to buy this Gang Hideout for $1,000?","Buy Hideout","Yes","No"))
if("Yes")
if(M.hideoutbuyer)
M << "You already bought a hideout!"
return
if(src.buying)
usr<<"Someone is currently attempting to purchase this hideout! Wait your darn turn."
return
src.buying=1
if(M.cash < src.cost)
M <<"Error: Insufficient Funds-Come back when you're actually worth money."
src.buying=0
return
if(src.gang_name!= "")
M << "This hideout already belonds to someone! You better run before they see you!"
src.buying=0
return
else
src.gang_name=M.gang
for(var/turf/houses/House1/A in world)
H.gang_name=M.gang
hideouts.Add(A)
var/savefile/B=new("World Save Files/hideouts.sav")
B<<hideouts
src.hideoutowner=M.name
M.cash -= cost
M <<"Purchase Successful."
M.hideoutbuyer=1
src.buying=0
return
else
M << "You must be in a gang to purchase a gang hideout!"
src.buying=0
return
else
if(src.gang_name==M.gang)
M <<"Welcome to [src.gang_name]! Enjoy the life of crime"
M.loc=locate(122,194,1)
return
else
M<<"This gang hideout belongs to [src.gang_name]!"
return

world
New()
..()
var/savefile/A=new("World Save Files/hideouts.sav")
A>>hideouts
if(isnull(hideouts))hideouts = new /list
Del()
..()


Problem description:
When using the savefile editor, it shows that the savefile generates the gang_name, however, upon rebooting the game, it doesn't reload the gang_name into the purchased hideout. I am a little confused at this point on what I need to do to get this correct.
Your first step should be adding some debugging output along the way, to make sure things are being saved/loaded and to find out exactly where things go wrong. Once you know that you'll be better able to figure out how to fix it.

I recommend outputting the contents of the hideouts list at both points where you save and load it, including outputting the values of the variables associated with the items in the list.
In response to Nadrew
Nadrew wrote:
Your first step should be adding some debugging output along the way, to make sure things are being saved/loaded and to find out exactly where things go wrong. Once you know that you'll be better able to figure out how to fix it.

I recommend outputting the contents of the hideouts list at both points where you save and load it, including outputting the values of the variables associated with the items in the list.

I went ahead and did this. I believe it has to do with the way it is loading when a reloading the game. Everything is saving properly. However, loading is the issue. Based on what I did, do you have any tidbits of advice for getting the variable gang_name to load properly? I used the savefile editor again and the savefile is properly saving the variable name.
I imagine the biggest issue is that you're using turfs to handle this instead of a dummy object or doing the save/load manually based on some kind of ID variable so you're not trying to replace a turf with a new turf (which gets a bit weird).

So if you want to use turfs for it you'd do something like set an ID for that turf in the map editor and use that ID in turf/New() to load the variables for that specific turf from a file just for that ID without actually creating a new instance of the turf (you'd just be setting variables on an existing turf).

More ideally though is using something like a dummy object that handles this, objects handle being created and destroyed on the fly much better. Then you'd just create and save the object outright like you're doing now, then loading it would go a lot smoother, it doesn't even actually have to exist on the map so you could use a datum that's just stored in an associative list then reference that datum using coordinates and/or an ID, that would save you quite a bit of overhead since you can easier control the amount of variables associated with a datum.

Either way though, your problem is you're trying to create a new turf in a fairly wonky way that's not actually going to place the turf at the location of the one you saved, since x, y, and z are /tmp variables and not saved by default. You're essentially loading a bunch of turfs into the void since they have no coordinates.

Full on saving turfs is rarely an ideal method, though, especially if you're only needing to save a few specific variables.
This was extremely helpful. Much appreciated.