ID:2485309
 
I am aware this is probably extremely stupid, but I would like to be able to export world.contents -- basically, every datum, at a single point in time.

/client/verb/welp()
set category = "Welp"
set name = "Export"
set desc = "This is a horrible idea and will break everything"
var/savefile/F = new()
var/txtfile = file("savefile.txt")
world << "Starting..."
for (var/D in world)
world << " Adding [D] ...")
F[D] << world[D]
F.ExportText("/", txtfile)
world << "Done (if it got this far)"


This particular attempt fails with "bad index" immediately after the "for". I can get it to print repeatedly if I switch to "Adding \ref[D]" and remove the F[D] << world[D], but that doesn't quite do what I want.


I do not really have concern for how long it takes (as long as it is not on the span of hours). Disk space is also mostly a non-issue.

The goal I have is getting a text-based dump of the current state of the world and everything in it, ideally with only unique instances (so no recursion loops, etc).</<>
Savefiles can't have objects as directory indexes.

Also, world has no valid indexing operation.

Change this line to:

       F[D] << world[D]


       F << D


Good luck.
At this point, why not just...
var savefile/s = new
s << world.contents
s.ExportText("/", "savefile.txt")

Also, why wouldn't you want recursive loops if you want the actual state of the world?
An object referring to itself should store a reference to itself, not a reference to another object.
Likewise, an object referring to another object in the world should store a reference to the other object, not a reference to its own copy of that object.
With the savefile system as it currently is, there's no way to preserve those references unless you use a single savefile << output operation.