ID:927940
 
Keywords: exist, verb
(See the best response by Ter13.)
Is there a way to check if a path to a verb exists within the code so I can remove it from a list if it doesn't exist anymore?
http://www.byond.com/forum/?post=162359#comment717085
http://www.byond.com/forum/?post=152159#comment720377

typesof() will help, although adding the verbs to a list is a much better option IMO.
Thanks, first thread helped and I learned some.
Sorry to ask for help again but now I'm not sure how to send a message saying that the verb is no longer available. I have a list of the players verbs save in the save file and loop through them checking against all possible mob verbs but I just get an error when it gets to the removed verb.
Hey shades, since ATHK helped you out, you ought to mark his response as helpful in the top right corner of his post. It's useless nerd-points, but it is a nice thing to do nonetheless.

For your second question, you really shouldn't be saving verbs at all.

This, however, seems to be a problem with savefile forward-compatability after you have removed a verb from the game's codebase, right?

Can you show me the code for what you are trying to do?
 mob
proc
saveproc()
if(global.pwiping)
return
if(src.cansave)
var/savefile/save
save = new ("Players/[src.key].sav")
save["mob"] << src
save["x"] << src.x
save["y"] << src.y
save["z"] << src.z
save["guildid"] << src.guildid
save["verbs"] << src.verbs
//Write(save)

var/savefile/load
var/list/tempverbs
load = new ("Players/[usr.key].sav")
load["mob"] >> usr
load["x"] >> usr.x
load["y"] >> usr.y
load["z"] >> usr.z
load["verbs"] >> tempverbs
var/list/mob_types = typesof(/mob)
var/list/verb_assoc = list()
for(var/r in mob_types)
verb_assoc += typesof("[r]/verb/")
for(var/V in tempverbs)
if(verb_assoc.Find(V))
usr.verbs += V
else
usr << "Failed..."
Best response
                        for(var/V in tempverbs)
if(verb_assoc.Find(V))
usr.verbs += V
else
usr << "Failed..."


You shouldn't be using usr here. Change the usrs to src. It won't fix your error, but again, you really shouldn't be saving the verbs list.

if you are, though, I'd save them as text:

F.cd = "verbs"
F << src.verbs.len
for(var/v in src.verbs)
F << "[v]"
F.cd = ".."


And when you load it:

F.cd = "verbs"
var/len = 0
F >> len
var/vpth
for(var/count=0;count<len;count++)
{
F >> vpth
vpth = text2path(vpth)
if(vpth!=null)
if(!src.verbs.Find(vpth))
src.verbs += vpth
}


The DM guide says that text2path won't convert the text to a path if the type is invalid, and will return null. This should make your verb saving forward compatible.

Let me know if this doesn't work. By all indications, though, it ought to.
Thank you that solves it but if you wouldn't save the verb list then you would prefer to check and give verbs during character loading?
Nope. In all honesty, I wouldn't use clickable verbs at all. It's kind of one of the things that make your average internet gamer avoid BYOND. Not only that, but it's a gameplay abstraction, and makes you look at something that isn't on the screen.

Personally, I'd rather see a well-made HUD and macro setup.

On the other hand, if you absolutely have to use unlockable verbs, I'd attach the verbs to objects, and put them in the player's contents. If you save the objects, the verbs will automatically be added to the player once the object is instantiated. In some very, very specific cases, you will want to save verbs, but as a matter of practice, you shouldn't have to do it for every object.