ID:140071
 
Code:
world
Del()
var/list/tiles = list()
for(var/tile/t in world)
tiles += t
for(var/i=1,i<20000,i++)
if(length(tiles))
var/savefile/f = new("world/tile[i].sav")
var/tile/t = pick(tiles)
f["x"] << t.x
f["y"] << t.y
f["z"] << t.z
t.Write(f)
tiles -= t
..()
New()
..()
for(var/i=1,i<20000,i++)
if(fexists("world/tiles[i].sav"))
var/savefile/f = new("world/tiles[i].sav")
var/tile/t = new/tile
t.Read(f)
f["x"] >> t.x
f["y"] >> t.y
f["z"] >> t.z


Problem description:

Umm, this is probably a noobie, or elementary mistake. I've gotten pretty good at coding, but world object saving isn't something i've made before.

For some reason, it saves them all, but it wont load them. Any ideas?
the file names are different. "tile" "tiles"
Also: you really shouldn't be doing that. Just write the tiles list to a single savefile and you're done. Like so:

var/savefile/F = new("tiles.sav")
F["tiles"] << tiles

// And to read it:
var/savefile/F = new("tiles.sav")
var/list/L
F["tiles"] >> L


To save the x,y,z coordinates, you will need to override tile/Write() and tile/Read(), like so:

tile
Write(var/savefile/F)
..()
// Only save our coordinates if we are on a turf
if(isturf(loc))
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
var/turf/T = locate(F["x"],F["y"],F["z"])
// We might not have actually saved x,y,z values, so only locate us there if we did
if(T)
loc = T
In response to Garthor
Thank you Garthor.

I'm starting to feel like a noob again, I had no idea if I save Coords in Write, and then wrote the list instead, loading the list like that would do it all automatically.

Worked like a charm!

(Reason being was, I thought reading a list would create new ones, and wouldn't assign location. Guess I was wrong.)
Helps a lot, so thanks!