ID:139350
 
Code:
book
Write()
contents=new/list()
..()
player
Write(savefile/F)
F["version"] << SAVEFILE_VERSION
..()
F["save_x"] << x
F["save_y"] << y
F["save_z"] << z

Read(savefile/F)
loc = locate(F["save_x"],F["save_y"],F["save_z"])
var/version
F["version"] >> version
if(isnull(version)) version = 0

switch(version)
if(1)
if(isnull(hp)) hp = new /restricted(0,100,100)
..()
update_grids()


Problem description:
In my game, I save an object that contains a list of objects. For some reason, when I look at my savefile, it shows all of the objects there (only using one for testing purposes), but when I load it, it becomes null. The /spell type doesn't have any overridden Read/Write procs, so I'm not sure what went wrong in loading the list.

The only read/write procs I have are on the player himself, and a Write on the book itself, but it only destroys the contents, not the list.

Savefile:
equipment = list("Book" = object(".0"),"Body" = object(".1"))
.0
type = /book/Epic_Book
spells = list(object(".0"),null,null,null,null,null,null,null,null,null)
.0
type = /spell
owner = object("../../../../..")
initial_components = list(object(".0"))
.0
type = /root/igni
uses = object(".0")
.0
type = /restricted
initial = -7
minimum = 0
current = -7
maximum = -7
current_components = list(object(".0"))
.0
type = /root/igni
uses = object(".0")
.0
type = /restricted
initial = -7
minimum = 0
current = -7
maximum = -7
component_count = list("igni" = 1)
element = 128
range = 0
power = 5
speed = 0
sustain = 0
average_tier = 1
name = "Igni"
icon_state = "igni1"
suffix = "Equipped"
overlays = list(object("../../.1/overlays",6))


But after I load, the whole .0 disappears. :(
Bump. Am I missing some important detail that someone might need?
In response to DivineTraveller (#1)
Heres whats happening... The saving as you guessed works just fine. I profiled your code during loading and I noticed something I didn't expect to see. It called spells/new, and as you know, if spells/new is called without any parameters, it deletes itself.
Byond seems to call new on entity's in saved lists like a mobs contents. I don't know if this is expected behavior or if it does this with anything else. I need to run more tests tomorrow to see if this is a bug with byond.
Now that I told you where the problem is, You know what information your missing. :p

Heres a demonstration of this problem with code if my explanation was not sufficient.

http://pastebin.com/DcfYTdUq