ID:166881
 
I've been playing around with this concept to make my inventory work... but nothing is working. Here's a small part of my saving script so far...
mob
var/invetory[0]
Write(savefile/F)
saved_x = x
saved_y = y
saved_z = z
F["Inventory"] << src.inventory
..()

Read(savefile/F)
F["Inventory"] >> src.inventory
..()
Move(locate(saved_x,saved_y,saved_z))

Logout()
world << "[src.name] has logged out."
var/savefile/F = new("Save/[src.ckey].sav")
Write(F)
del src
mob
proc
//SAVING/LOADINg
Save()
var/savefile/F = new("Save/[src.ckey].sav")
Write(F)
return
Load()
var/savefile/F = new("Save/[src.ckey].sav")
Read(F)
return


I believe that the problem is that the list I'm trying to save is composed of objects.

I've been trying to make this work for so long.... any help would be greatly appreciated.
would it be the del?
    Logout()
world << "[src.name] has logged out."
var/savefile/F = new("Save/[src.ckey].sav")
Write(F)
--> del src

im not sure, maybe im totally off
In response to Oblivon_2
Oblivon_2 wrote:
would it be the del?

No, it wouldn't. All the saving and such is finished before the src is deleted.
In response to Kalidascorp
owned.
In response to Oblivon_2
What the hell at 'owned'? If you don't <code>del src</code> in Logout(), the mob is just going to stand there, clientless.
OK...After much more experimenting, I was able to devise a code that found what the problem was, and exploited it. Please test it out(it's short) and help me find why this is happening...
Test_INVENTORY_SAVE()
set category = "DEBUG1"
var/list/INV = list()
var/savefile/F = new("Test/INVENT.sav")
for(var/obj/O in src.contents)
INV.Add(O)
src << "Saving... [O]"
F["Inv"] << INV
//PART 2: Checks what objects are loaded...
src << "Listing saved objects..."
sleep(3)
var/list/INVt = list()
F["Inv"] >> INVt//puts the list saved above into here
for(var/obj/o in INVt)
src << "[o] was saved successfully."//if it detects an object, display which object was saved.
sleep(1)


NOTE: This isn't my actual saving code, just a nice system to show me what's going on...

Problem Description (in case you don't feel like testing out the code yourself >.>): Basically, EVERYTHING works fine... up until this line...

F["Inv"] >> INVt

The weird thing here, is that it SOMETIMES works. I mean it. Completely random. There isn't no "Yes it works." or "No it doesn't.". In the code above, every so often you try it it actually detects the objects that were saved a few lines back.
This freaks me out o.0;

Any help is still appreciated :-)