No, not like how Superman would. I mean I'm trying to save World variables to a savefile. Is it possible?
I've tried calling Write(), but that doesn't work.
Edit: To be more specific, I'm setting up a Player ID system, that increases by 1 every time a new player connects to the server and makes a character. I have defined a variable called total_ids (not a mob variable, just var/total_ids), and it is equal to the total number of clients that have joined and made a character. I need to know how to save this variable to a savefile, so it doesn't revert back to 0 every time the server reboots.
ID:161189
Jun 5 2008, 6:59 am
|
|
In response to Kaioken
|
|
@ Kaioken
Ok, I understand, but... How am I supposed to save the global variables to a savefile, and then load them? *Sorry if you already addressed that. Even though I read your whole post, I might not have seen it.* |
In response to JaxxMarron
|
|
JaxxMarron wrote:
How am I supposed to save the global variables to a savefile, and then load them? var/my_global_variable = 3 *Sorry if you already addressed that. Even though I read your whole post, I might not have seen it.* I believe I have, but an illustration does make it easier to understand these things. |
In response to Kaioken
|
|
Kaioken wrote:
JaxxMarron wrote: > var/my_global_variable = 3 *Sorry if you already addressed that. Even though I read your whole post, I might not have seen it.* I thought I had tried that... But maybe I did it wrong... Thanks, I'll try it again right now. Edit: Awesome! It worked perfectly! I guess I didn't try that earlier. Thanks again! |
You shouldn't be calling Write() anyway. Write() should be used for doing any pre-save processing (such as nulling out the icon to reduce savefile sizes). To write to savefiles, you should always use the << operator.
|
In response to Hazman
|
|
That's not very accurate.
Hazman wrote: You shouldn't be calling Write() anyway. Write() should be used for doing any pre-save processing (such as nulling out the icon to reduce savefile sizes). Overriding Write() can be used to do that, yes. But it can also be used by calling it manually, to write an object into a savefile. To write to savefiles, you should always use the << operator. Alternatively, you can call the Write() and Read() procs yourself; the << and >> operators call those themselves (although the methods obviously have differences of course. If you're interested, I think this is covered explicitly in the DM Guide) anyway. Of course, though, in this case you're not saving an object, only a single variable, so there is no place for the object procs Read() and Write(). |
Sure it's possible. It is done the same way saving any individual variable is done. I don't quite understand what's so difficult about it.
Look up procs before you try to use them. The Write() proc is of datums - it is datum/Write(). If you look up /datum, you'd see that /world is not a datum, amongst other types as well. Therefore, it does not have that proc. Besides, trying to save the entire /world object isn't a good idea anyway. Save the variables you want to keep and restore them on world/New().
EDIT in response to EDIT:
That isn't a world variable. These are (you can't define custom vars on /world.). It is a global variable, though.
Well, if you already know how to save other things, this is easy, since again, it is no different. You'd use the savefile operators << and >> to save and load the variable by accessing it as normal, the way you always do.