ID:139585
 
Code:
proc/saveworld()
var/savefile/W = new("World_Save")
for(var/turf/T in world)
W << T
Write(W)
proc/loadworld()
if(fexists("World_Save.sav"))
var/savefile/W = new("World_Save")
Read(W)


Problem description:

WorldGenerator.dm:210:error: Write: undefined proc
WorldGenerator.dm:214:error: Read: undefined proc

2 errors, 0 warnings


Doesnt. Make. Sense.

What I am trying to do is save all of the world's "/turf/" files into a savefile for use later. These maps are randomly generated. Random generation of the maps works fine, but for some reason this portion of the code does not, and these are built-in procs =/

Can someone tell me what I am doing wrong (or if there is another way of having what I wish to accomplish done)? Its probably something simple I just cannot see (-.-)

edit: Not all of the loadWorld proc was posted here, but there are no errors after that point.
Read() and Write() are procs that belong to the type /datum. They are not global. You do not, in fact, need to be calling them at all, though you will be needing to use the >> operator to load all the turfs you wrote into the savefile. Use the savefile's eof variable to know when to stop.

Also note that writing every single turf into the savefile is quite likely to be incredibly slow, unnecessary, and prone to some fun errors when you save something you didn't expect.
In response to Garthor
Thankyou.. did not realize I did not need those there.

Yeah I realized it could be a little slow saving/loading every tile (considering some maps I make with this are 250x250 or more), any suggestions on a faster method? ^.^

I was thinking since all of the /turf/ datums are not changed in any way, that I could basically save each map file as straight text, using one-letter per tile. As in water = W, land = L and such, and save them as something like this:

WWWWWLLLWWW
WWWWLLLLWWW
WWWLLLLLLWW
WWWWLLLLWWW
WWWWWWLLWWW


Although it would be encrypted of course.. just-in-case someone tried to mess with it. To my knowledge it would be fast (faster at least).

Any other suggestions / ways I should/could do this? =)
In response to KingCold999
Any other suggestions / ways I should/could do this? =)

That is a discussion for the Design Philosophy forum. :)