ID:150972
 
Hello all! I've been gone from BYOND for a looong time, and just recently picked up work with one of my games (the engine was nearly complete when I wandered away from it 5 months ago). I've been kinda lurking in the forums for the past week or so, but now I have a major problem that forces me to show myself and beg for help :-)
Maybe I'm not quite understanding savefiles completely, but does anyone know of a way to save an atom's verbs list to a savefile? My interface (which, if I may say so myself, is quite nifty) involves a lot of verbs being added at runtime to objects in the usr's possession. It works quite well until a save/load is required, and the verbs all get dumped. Here's my predicament:
You can't load verbs directly like you would with another variable, since it can't be written to. My next try was to save the verbs into another list, load that, then go through it one by one and add them to the verbs list. That, however, gives an error, since it for some reason doesn't know what to do with the list of verbs.
This might be hard to explain, so I'll include some code:

obj/Write(savefile/F)
..()
var/V
var/Verbs=list()
for(V in verbs)
Verbs += V
F["verbs"] << Verbs

obj/Read(savefile/F)
..()
var/V
var/Verbs=list()
F["verbs"] >> Verbs
for(V in Verbs)
src.verbs.Add(V)

When executed (during Read()), it gives an "Warning: type read from file (whatever the verb's path is) is not defined." for each verb saved, and "wrong type of value for list" at src.verbs.Add(V). It seems like there's no way to do what I want.. if thats the case, then this post becomes a feature request. I need more control over the verbs list! :-)

-AbyssDragon</<>
On 6/18/01 11:52 pm AbyssDragon wrote:
Maybe I'm not quite understanding savefiles completely, but does anyone know of a way to save an atom's verbs list to a savefile?

My suggestion would be to track the verbs installed yourself, and store out the information you need to restore the verbs.

You could do this one by one or by group.

It would work something like this:

Give players a verb_names list. When you add a verb or group of verbs, add a unique name to that list. In the player's Read() proc, go through the list and add the appropriate verbs:

mob/Read()
// Let auto-stuff read in things.
..()

for (var/vname in verb_names)
switch(vname)
if ("god_verb")
verbs += /mob/proc/god
if ("goddess_verb")
verbs += /mob/proc/goddess

Etc. Obviously this is a bit easier if you can group the verbs.
In response to Deadron
On 6/19/01 12:48 am Deadron wrote:
On 6/18/01 11:52 pm AbyssDragon wrote:
Maybe I'm not quite understanding savefiles completely, but does anyone know of a way to save an atom's verbs list to a savefile?

My suggestion would be to track the verbs installed yourself, and store out the information you need to restore the verbs.

You could do this one by one or by group.

It would work something like this:

Give players a verb_names list. When you add a verb or group of verbs, add a unique name to that list. In the player's Read() proc, go through the list and add the appropriate verbs:

mob/Read()
// Let auto-stuff read in things.
..()

for (var/vname in verb_names)
switch(vname)
if ("god_verb")
verbs += /mob/proc/god
if ("goddess_verb")
verbs += /mob/proc/goddess

Etc. Obviously this is a bit easier if you can group the verbs.


ummm.. wont both of these make mojor login lag?
In response to jobe
On 6/19/01 9:28 am jobe wrote:
ummm.. wont both of these make mojor login lag?

No.
In response to Deadron
I was hoping there might be a cleaner solution. Your solution will work, and I had considered it before, but it just seems like BYOND is so close to being able to do it my way that it really should be able to.

-AbyssDragon
In response to AbyssDragon
On 6/19/01 3:15 pm AbyssDragon wrote:
I was hoping there might be a cleaner solution. Your solution will work, and I had considered it before, but it just seems like BYOND is so close to being able to do it my way that it really should be able to.

This sounds like a reasonable-enough request (more of a bug-report, really). I'll forward it on to Dan. I think Deadron's workaround should do the trick in the meantime, though.
In response to Tom
On 6/19/01 3:25 pm Tom wrote:
This sounds like a reasonable-enough request (more of a bug-report, really).

In defense of Dantom, I'd call it a feature request to consider verbs as savable data...

It's not obvious up front that that is a desirable thing...though clearly now that several people have requested it, it is a desirable thing.

Hopefully it will be easy to distinguish between manually added verbs and verbs that the mob has circumstantially at save time -- that is, verbs the mob only has at that moment because they are standing next to a door or something.
In response to Tom
Man, you put this in, and you can have my seventh, eighth, and ninth born children, too.
This sounds like a reasonable-enough request (more of a bug-report, really). I'll forward it on to Dan. I think Deadron's workaround should do the trick in the meantime, though.

Good to have you back!

Currently, there is no way to save a verb by direct reference, which is why you were having trouble. I can probably remedy that. I'm working on some savefile stuff right now, so I'll see what I can do.

The trickier question is how to handle saving of the verbs list in the default saving/load procedures. I avoided that, because to be consistent with the behavior of other variables, it should only save modifications. So if no changes to the verbs list have been made, it would not save anything. The point of that is to allow you to add new verbs in the code and not have all those changes overwritten when loading the savefile.

--Dan