Verb Help DB (#22)

(an instance of Root Class made by Hacker)

     A `help database' that knows about all of the documented verbs.



VERB SOURCE CODE:

find_topics:
if ($code_utils:parse_verbref(what = args[1]))
    "... hey wow, I found it!...";
    return {what};
else
    return {};
endif
.


get_topic:
"Help facility for verbs that people have bothered to document.  If the argument 
is a verb specification, this retrieves the code and prints any documentation lines 
that might be at the beginning.  Returns true if the arg can actually be interpreted 
as a verb specification, whether or not it is a correct one.";
set_task_perms(caller_perms());
if (!(spec = $code_utils:parse_verbref(args[1])))
    return 0;
elseif ($command_utils:object_match_failed(object = $string_utils:match_object(spec[1], 
player.location), spec[1]))
    return 1;
elseif (!(hv = $object_utils:has_verb(object, spec[2])))
    return "That object does not define that verb.";
elseif (typeof(verbdoc = $code_utils:verb_documentation(object = hv[1], spec[2])) 
== ERR)
    return tostr(verbdoc);
elseif (typeof(info = verb_info(object, spec[2])) == ERR)
    return tostr(info);
else
    objverb = tostr(object.name, "(", object, "):", strsub(info[3], " ", "/"));
    if (verbdoc)
        return {tostr("Information about ", objverb), "----", @verbdoc};
    else
        return tostr("No information about ", objverb);
    endif
endif
.


dump_topic:
set_task_perms(caller_perms());
if (!(spec = $code_utils:parse_verbref(args[1])))
    return E_INVARG;
elseif ($command_utils:object_match_failed(object = $string_utils:match_object(spec[1], 
player.location), spec[1]))
    return E_INVARG;
elseif (!(hv = $object_utils:has_verb(object, spec[2])))
    return E_VERBNF;
elseif (typeof(vd = $code_utils:verb_documentation(hv[1], spec[2])) != LIST)
    return vd;
else
    return {tostr(";$code_utils:set_verb_documentation(", $code_utils:corify_object(hv[1]), 
",", $string_utils:print(spec[2]), ",$command_utils:read_lines())"), @$command_utils:dump_lines(vd)};
endif
.



PROPERTY DATA: