ID:148732
 
The following is my map code (originally designed by Foomer). I need it to save underlays, however. Whenever I use this, it locks my game (Not Responding). The only data I need saved from the turfs are type and underlays.


    wsave()
var/savefile/F = new/savefile("SavedMap.sav")
F << world.maxx
F << world.maxy
for(var/turf/T in world)
F["type"] << T.type
F["underlays"] << T.underlays

wload()
var/savefile/F = new/savefile("SavedMap.sav")
F >> world.maxx
F >> world.maxy
for(var/turf/T in world)
var/turftype
var/underl[]
F["type"] >> turftype
F["underlays"] >> underl
T = new turftype(T)
T.underlays = underl

same here even though mine only has turfs
Polatrite wrote:
The following is my map code (originally designed by Foomer). I need it to save underlays, however. Whenever I use this, it locks my game (Not Responding). The only data I need saved from the turfs are type and underlays.


    wsave()
> var/savefile/F = new/savefile("SavedMap.sav")
> F << world.maxx
> F << world.maxy
> for(var/turf/T in world)
> F["type"] << T.type
> F["underlays"] << T.underlays

Two problems I'm seeing here: First, you're saving "type" and "underlays" over and over, not by position.

Second, it would probably help you to call sleep() occasionally.
You can debug this by adding these lines to the for loop:
<dm>world << "Saving turf at [T.x],[T.y],[T.z]"
sleep()

This may all be moot, since the library I'm working on for digitalBYOND is going to handle map saving.

Lummox JR
After toying around a bit, I've decided this is how I want my saving to work. I created another /atom, /atom/structure, with a parent_type of /turf. Now, I need to have all these saved, with their type, x, y, and z. I also need them to load properly, be newly created at their designated locations. Currently, this is what I have for code. As you can tell, I've been toying with it quite a bit, I think using lists will help out quite a bit, but I am very poor with savefiles AND lists, and since I'm trying to use both.....

    wsave()
fdel("SavedMap.sav")
var/savefile/F = new/savefile("SavedMap.sav")
for(var/mob/enemy/saved/T in world)
F["[T.name],[T.x],[T.y],[T.z],[T.type]"] << T.type
F["[T.name],[T.x],[T.y],[T.z],[T.x]"] << T.x
F["[T.name],[T.x],[T.y],[T.z],[T.y]"] << T.y
F["[T.name],[T.x],[T.y],[T.z],[T.z]"] << T.z
usr << "[T] saved to F"
for(var/atom/structure/T in world)
F["[T.name],[T.type],[T.x],[T.y],[T.z]"] << list(T.type,T.x,T.y,T.z)
/* F["[T.name],[T.x],[T.y],[T.z],[T.x]"] << T.x
F["[T.name],[T.x],[T.y],[T.z],[T.y]"] << T.y
F["[T.name],[T.x],[T.y],[T.z],[T.z]"] << T.z*/

usr << "[T] saved to F"

wload()
var/savefile/F = new/savefile("SavedMap.sav")
for(var/T in F)
usr << "[T] in F"
for(var/T in F)
var/ntype
var/X
var/Y
var/Z
F >> ntype
F >> X
F >> Y
F >> Z
usr << "Creating [ntype] at [X],[Y],[Z]"
T = new ntype(locate(X,Y,Z))



Also, as you can see, there are a few mobs that need saving in here too. I may change these to structures at a later time, or now, if it is causing interference.


~Polatrite~