Layer Problems in Developer Help
|
|
Code:
proc ObjectSave() var/list/objects = new() var/savefile/F = new("Objects.sav") for(var/obj/O in world) if(O.owner) O.lastx = O.x O.lasty = O.y O.lastz = O.z objects.Add(O) F["All"] << objects ObjectLoad() var/list/objects = new() var/savefile/F = new("Objects.sav") F["All"] >> objects if(!length(objects)) world<<"<font color=blue>-Announcement-<font color=red><font size=1>ERROR:No objects to load</font>" return for(var/obj/B) if(B.loc && B.owner) del(B) for(var/obj/O in objects) if(O:Layer == 1) O.loc = locate(O.lastx,O.lasty,O.lastz) if(O:Layer == 2) O.loc = locate(O.lastx,O.lasty,O.lastz) if(O:Layer == 3) O.loc = locate(O.lastx,O.lasty,O.lastz) if(O:Layer == 4) O.loc = locate(O.lastx,O.lasty,O.lastz) if(O:Layer == 5) O.loc = locate(O.lastx,O.lasty,O.lastz) world<<"<font color=blue>-Announcement-<font color=red><font size=1>All objects hae been loaded by [usr]."
|
Problem description:When ever i load the objects some times layer 2 objects be under layer 1 objects. How can i fix this problem?
|
When objects in the savefile cycle through the loop, they cycle through it one at a time, going through every if filter you have, and place themselves if they are layer 1-5. Assuming that those are the only layers you have, what I have up there is exactly the same, just shorter.
To set objects in the way you want to, you'll have to use multiple lists, like the below. I'll use sleep() procs to prevent lag spikes.
But, I do not see the reason for deleting all of the objects around unless you use Load Map only at startup. And, in any case, my system works just fine while loading the objects. No extra varialbes of anything. I even customized it for your use, if you want it.
But I do believe the problem is that you may set the layer when the object is built. Refrain from doing that unless nesseccary. Other than that, you'll have to use one of the following up there.