I've been trying for hours to save my datums.
There was an article about datums, could someone help me with saving them.
ID:159329
Mar 29 2009, 5:16 pm
|
|
Read the DM Guide's savefile chapter and relevant entries in the DM Reference. Datums are saved just like any other object - which can also be saved similarly to any value at all anyway. I wonder what's so difficult to keep you for hours, since if I had to take a guess I'd say you've implemented at least saving of mobs before. This isn't any different.
|
In response to AJX
|
|
You forgot the Write(F) line ^-^
|
In response to Spunky_Girl
|
|
Actually, when you use the '<<' operator to save something you call the Write() proc, and when you use '>>' operator to read something you call the Read() proc.
So, no need to use it. |
In response to Spunky_Girl
|
|
No, he didn't. It's a somewhat common misconception, but you don't actually realize what that proc does - it's for saving objects into a savefile, and it's an object proc, not a global (or a savefile, of course) proc. So that would really compile as src.Write(). His usage of << already saves the object and calls Write() internally; for more info refer to the Reference & Guide.
|
In response to Kaioken
|
|
If he wanted to save all the non-tmp variables of the datum, couldn't he just call MyDatum.Write(F)? In case he didn't want to use << for all the variables manually, I mean.
|
In response to Kaiochao
|
|
Yes... This is correct.
|
In response to Kaiochao
|
|
He could, but apparently you didn't read my post or something (?), since it already said using << on the object reference (like AJX did in his psuedocode) does do a complete object save by calling Write(), though the result is different from calling only Write() alone. Same with >> and Read(), so both methods shouldn't be mixed.
|
In response to Kaioken
|
|
By "mixed" do you mean you should never use the shift operators in Read/Write procs and vice-versa? or do you mean they should just never be used at the same time in a proc?
var/list/stuff = list() |
In response to Spunky_Girl
|
|
Spunky_Girl wrote:
By "mixed" do you mean you should never use the shift operators When used with savefiles, they're not really shift operators of course, since they're not shifting anything. The DM Reference calls them "savefile operators". in Read/Write procs and vice-versa? or do you mean they should just never be used at the same time in a proc? The latter couldn't be accurately said since you could potentially have multiple dealings of saving/loading objects in a single proc, etc. You generally shouldn't mix them within the same saving/loading context - they have different uses and you shouldn't use both, doing which would only potentially cause harm and it's pointless anyway. It looks like you still don't completely understand the Write() and Read() procs, as your first example doesn't even involve objects and wouldn't compile either, so allow me to illustrate: var/savefile/F = new If you do this, you've obviously just saved the object twice. No point there. You should only use one of the methods. Additionally, since the 2 methods (using savefile operators or savefile procs) work a little differently you need to stick with one method, ie don't use >> to load what you've saved by calling Write(); use Read(). //Examples: Also, what you've done in the 2nd example, overriding Write(), is of course different. Overriding the savefile procs allows you to have control on how objects are saved/loaded, which is of course handy, and works irregardless of what saving method is used since the operators use and call Read()&Write() as well. For more info or if you still have questions do consult the DM Guide & Reference. It's all documented there so reading them before asking further questions is recommended. The DM Guide has a whole chapters on savefiles and how to use them and the DM Reference's entries on the savefile procs and operators explain how those work. =) |
In response to Kaioken
|
|
Alright I get it now. Thanks. I know my first example wouldn't load because Write()/Read() are atom based procs ("datum" as said in the reference).
|
In response to Spunky_Girl
|
|
I figured out the problem a few days ago, forgot to come back and let you know.
|
Or you can be all over-active and do it this way: