ID:935543
 
Keywords: building, game, icon, mapsave
(See the best response by Albro1.)
<>
proc
SaveObjects()
var/savefile/F = new ("Map.sav")
var/list/L = new
for(var/obj/O in world)
if(!O.owner) continue
if(O.owner)
O.saved_x = O.x
O.saved_y = O.y
O.saved_z = O.z
O.saved_owner = O.owner
O.saved_object = O
L += O
F[""] << L


proc/LoadObjects()
var/savefile/F = new ("Map.sav")
var/list/L = new
F[""] >> L
if(!L) return
for(var/obj/O in world)
for(var/obj/O in L)
O.loc = locate(O.saved_x,O.saved_y,O.saved_z)
O.owner = (O.saved_owner)
O = (O.saved_object)</b>

obj
var
saved_x
saved_y
saved_z
saved_owner
saved_object
mob/verb
SaveObjects()
SaveObjects()
LoadObjects()
LoadObjects()</b>

The problem is that the code does not save the layering. I know I've made the object's layer right, because I've used the wording codes. Like
wooden_floor layer=TURF_LAYER...And when the map saves and than you load it, the floor layer is over an OBJ_Layer which is a higher layer. Can anyone tell me why?


use the
 tags please.
Alright,
 tags were added.
Well you might want to actually name the variable in the save file, and I'm not sure if you can save lists in the way you want to use them.
I've obviously tried.
Best response
Try using obj/New() to set the layer, because loading objects creates new instances of them.
All right, I'll try it right now!
Okay, so, I've fixed it. But, I've tried the obj/New() and gotten a proc error. But, thank you anyways!
In response to Audio freak XD
Mind posting explaining how you fixed it for future referance? It's fine if not.
It's too embarrassing to say NNAAAAHH. ):
But, it's pretty funny. So I went to put a var in
obj/var
called saved_layer. I've installed it to map save and load, it turned out, Map Save was set backwards. :/

With that var writing the object's layers. Example

O.layer=O.saved_layer//Backwards! oops!
In response to Audio freak XD
Lol. Thank you for posting that.
No problem!
This isn't really completely relevant, but you may want to include a type of obj that isn't saved, that way you have a type reserved for things like projectiles, things you wouldn't want saved.
...Wow! You've obviously failed to read the code. If the object has a owner, it saves...so therefore, projectiles will not be saved. :/
proc
SaveObjects()
var/savefile/F = new ("Map.sav")
var/list/L = new
for(var/obj/O in world)
if(!O.owner) continue
if(O.owner)
O.saved_x = O.x
O.saved_y = O.y
O.saved_z = O.z
O.saved_owner = O.owner
O.saved_object = O
L += O
F[""] << L
In response to Audio freak XD
I did read it through but a while ago, I just popped back here quick and didn't re-read.
Okay, anyway, yeah! It doesn't save any other object, except building objects, that players built.
Well that's good then.
Yep!