ID:140838
 
//This is my turf saving code, i have no problem with this
//part
proc
SaveTurfs()
var/savefile/F = new ("turfs.sav")
var/list/L = new
for(var/turf/build/T in world)
T.saved_x = T.x
T.saved_y = T.y
T.saved_z = T.z
T.saved_o = T.owner
L += T
F[""] << L
//This is the loading part, i get no errors
//here but it doesent load the owner
proc/LoadTurfs()
var/savefile/G = new ("turfs.sav")
var/list/S = new
G[""] >> S
if(!S) return
for(var/turf/build/T in S)
var/turf/build/NewT=new T.type(locate(T.saved_x,T.saved_y,T.saved_z))
NewT.owner=T.saved_o
//Can I please get some help on getting this to load the turfs owner? also the turfs owner is the usr's key
//Also it saves apon world closing and loads during world opening

>
Turfs cannot exist without a unique x,y,z location. So, by default, when you save and load a turf, their location is saved and loaded as well. When you create a new turf, it is always created over an old turf, deleting the old one. Therefore, the issue is when you create NewT, it is on top of T and so T is deleted. Despite the fact that you claim you are getting no errors, I'm fairly sure you are getting a "cannot read null.saved_o" error.

To solve your issue: remove all that saved_x, saved_o, blah blah blah stuff, as well as your loop in the LoadTurfs() proc. All your turfs are fully loaded on the line that you do G["]" >> S, so the if(!S) line is also pointless. If owner isn't being saved, then you have it declared as tmp, so change it to a normal variable.


Also: don't repost the same thing in multiple forums.
In response to Garthor
My apologies and no it has no errors at all originally i will try your way
In response to Iocamus
Thank you worked perfectly.
In response to Garthor
Oh wait,
I have this now
proc/LoadTurfs()
var/savefile/G = new ("turfs.sav")
var/list/S = new
G[""] >> S
for(var/turf/build/T in S)
new T.type
again no errors
it loads the owner but I get this runtime error
runtime error: bad loc
proc name: LoadTurfs (/proc/LoadTurfs)
usr: null
src: null
call stack:
LoadTurfs()
: New()
: New()
In response to Iocamus
I don't quite understand how you read "remove that loop" and interpret it as "don't remove that loop".
In response to Garthor
What do you mean?
In response to Iocamus
Delete the for() loop.