ID:140759
 
obj
var
saved_x
saved_y
saved_z

proc
SaveObjects()
var/savefile/F = new ("objects.sav")
var/list/L = new
for(var/obj/O in world)
O.saved_x = O.x
O.saved_y = O.y
O.saved_z = O.z
L += O
F[""] << L

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


mob/verb/SaveWorld() //the save verb
set category = "Staff"
SaveObjects()


mob/verb/LoadWorld() //the load verb
set category = "Staff"
LoadObjects()


Problem description:

The problem is.. the objects load, but they load every time I host the world.. which is good, but they keep stacking up like ..

1st host) everything is fine since the .sav wasnt made
2nd host) 2 items stacked
3rd host) 3 items stacked

etc

So you want them to delete once the host logs off? Or when the world is shut down?
In response to Drehdog7
I want them to delete when the world starts, before they load
In response to Karnaji
Karnaji wrote:
I want them to delete when the world starts, before they load

bump
In response to Karnaji
Bumping your posts just because they haven't gotten a reply after less than an hour isn't polite.
In response to Garthor
Garthor wrote:
Bumping your posts just because they haven't gotten a reply after less than an hour isn't polite.

sorry, still need help
In response to Karnaji
Karnaji wrote:
Garthor wrote:
Bumping your posts just because they haven't gotten a reply after less than an hour isn't polite.

sorry, still need help

The problem seems to be that when items are pre-placed on the map(on the actual coded map) it will duplicate them, but If I just save an item that is not naturally where it's supposed to be it saves correctly!? Can someone tell me wtf is going on?
In response to Karnaji
When you load an object, it's creating a new object, not magically replacing one. If you don't want the old objects sitting around, delete them before you create new objects.
In response to Garthor
Garthor wrote:
When you load an object, it's creating a new object, not magically replacing one. If you don't want the old objects sitting around, delete them before you create new objects.

How would I delete the old objects?.... I tried Del(O) ... but no dice
In response to Karnaji
bump
In response to Karnaji
You can't really get an answer to that one until you specify which objects are the ones you want deleted. Under what conditions would you want the objects placed on the map to remain, rather than be deleted?
In response to Karnaji
You have been advised not to bump a thread that is still on the first page, or before 24 hours have passed.
Please listen to this advice, or I fear you'll have to live with the consequences.
In response to Karnaji
Karnaji wrote:
How would I delete the old objects?.... I tried Del(O) ... but no dice

Garthor wrote:
You can't really get an answer to that one until you specify which objects are the ones you want deleted. Under what conditions would you want the objects placed on the map to remain, rather than be deleted?

You have yet to answer his question, but you still insist on bumping the topic? You could have just responded to him, which would have bumped the topic, and nobody would be annoyed.

Anyway: What you are going to need to do is, as Garthor said, decide if you want to get rid of the old object or keep the new one.
In response to AJX
AJX wrote:
Karnaji wrote:
How would I delete the old objects?.... I tried Del(O) ... but no dice

Garthor wrote:
You can't really get an answer to that one until you specify which objects are the ones you want deleted. Under what conditions would you want the objects placed on the map to remain, rather than be deleted?

You have yet to answer his question, but you still insist on bumping the topic? You could have just responded to him, which would have bumped the topic, and nobody would be annoyed.

Anyway: What you are going to need to do is, as Garthor said, decide if you want to get rid of the old object or keep the new one.

I hope making a reply doesn't count as early bumping..

Anyway.. I wanted to make it save the objects on the map, but only a single copy .. so like would I save and then delete all objects on the map? I just want to make it so items save when they are on the map... If anyone can help thanks a lot.

footnote: It will save but will keep adding items if the items are placed on the map by default..
In response to Karnaji
Okay then. Whenever you want to delete everything, just do:

for(var/obj/O)
del(O)
In response to Garthor
Garthor wrote:
Okay then. Whenever you want to delete everything, just do:

for(var/obj/O)
> del(O)


This will not work, it still creates duplicates.

proc
SaveObjects()
var/savefile/F = new ("objects.sav")
var/list/L = new
for(var/obj/O in world)
O.saved_x = O.x
O.saved_y = O.y
O.saved_z = O.z
L += O
F[""] << L

proc
LoadObjects()
var/savefile/F = new ("objects.sav")
var/list/L = new
for(var/obj/O)
del(O)
F[""] >> L
if(!L) return
for(var/obj/O in world) if(O.loc) del(O)
for(var/obj/O in L)
O.loc = locate(O.saved_x,O.saved_y,O.saved_z)
that's my code.. undefined var so far
In response to Karnaji
First, you didn't transcribe what I wrote properly. Second, you're already doing essentially what I told you to. You will obviously continue to get multiple objects if your savefile has multiple objects in it.
In response to Garthor
Garthor wrote:
First, you didn't transcribe what I wrote properly. Second, you're already doing essentially what I told you to. You will obviously continue to get multiple objects if your savefile has multiple objects in it.


..So it should delete objects.sav before it saves?
In response to Karnaji
I'm saying if you do not want to load multiple objects, then you will first need a savefile which does not have multiple objects.
In response to Garthor
Garthor wrote:
I'm saying if you do not want to load multiple objects, then you will first need a savefile which does not have multiple objects.


You realize what I want it to do is save the WHOLE MAP and then load the WHOLE MAP.. not specific objects
Page: 1 2