code utilities #59

Parent #79Owner #36Flags readSource QuestCore.db

Aliases: code utilities, code utils

60 verbs · 15 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
eval_dany any anyrx#5922
toint tonumthis none thisrxd#594
toobjthis none thisrxd#592
toerrthis none thisrxd#5910
error_namethis none thisrxd#593
show_objectthis none thisrxd#5960
show_propertythis none thisrxd#5917
show_verbdefthis none thisrxd#5922
explain_verb_syntaxthis none thisrxd#5919
verb_p*erms verb_permi*ssionsthis none thisrxd#592
verb_loc*ationthis none thisrxd#592
verb_documentationthis none thisrxd#5920
set_verb_documentationthis none thisrxd#5927
parse_proprefthis none thisrxd#5922
parse_verbrefthis none thisrxd#5919
parse_argspecthis none thisrxd#5926
prepositionsthis none thisrxd#594
short_prepthis none thisrxd#5914
full_prepthis none thisrxd#5911
get_prepthis none thisrxd#5918
_fix_prepsthis at/to thisrxd#5933
find_verb_namedthis none thisrxd#5914
find_last_verb_namedthis none thisrxd#5917
find_callable_verb_namedthis none thisrxd#5915
verbname_match(new)this none thisrxd#5916
find_verbs_containingthis none thisrxd#5930
_find_verbs_containingthis none thisrxd#5922
find_verbs_matchingthis none thisrxd#5929
_find_verbs_matchingthis none thisrxd#5922
_grep_verb_codethis none thisrxd#5916
_egrep_verb_codethis none thisrxd#5914
_parse_audit_argsthis none thisrxd#5929
help_db_listthis none thisrxd#5922
help_db_searchthis none thisrxd#5926
corify_objectthis none thisrxd#5912
inside_quotesthis none thisrxd#5910
verb_or_propertythis none thisrxd#598
task_validthis none thisrxd#596
task_ownerthis none thisrxd#596
argstrthis none thisrxd#5932
verbname_matchthis none thisrxd#5917
substitutethis none thisrxd#5921
show_who_listingthis none thisrxd#59133
_egrep_verb_code_allthis none thisrxd#5911
_grep_verb_code_allthis none thisrxd#5911
verb_usagethis none thisrxd#5940
verb_framethis none thisrxd#592
verb_all_framesthis none thisrxd#592
move_verbthis none thisrxd#5939
move_prop*ertythis none thisrxd#5932
eval_d_utilthis none thisrx#591
display_callersthis none thisrxd#593
callers_textthis none thisrxd#5932
set_property_value set_verb_or_propertythis none thisrx#5917
owns_taskthis none thisrxd#593
dflag_onthis none thisrxd#595
type_strthis none thisrxd#5910
dump_propertiesthis none thisrxd#5949
dump_preamblethis none thisrxd#5910
dump_verbsthis none thisrxd#5960

Properties

PropertyDefinerFlagsOwnerValue
_version#59rc#36"1.8.1"
_multi_preps#59rc#36{"off", "from", "out", "on", "on top", "in", "in front"}
_other_preps_n#59rc#36
list of 13{1, 2, 4, 4, 5, 5, 5, 6, 6, 9, 9, 12, 15}
_other_preps#59rc#36
list of 13{"using", "at", "inside", "into", "on top of", "onto", "upon", "out of", "from inside", "underneath", "beneath", "about", "off of"}
_short_preps#59rc#36
list of 15{"with", "to", "in front of", "in", "on", "from", "over", "through", "under", "behind", "beside", "for", "is", "as", "off"}
_all_preps#59rc#36
list of 28{"with", "using", "at", "to", "in front of", "in", "inside", "into", "on top of", "on", "onto", "upon", "out of", "from inside", "from", "over", "through", "under", "underneath", "beneath", "behind", "beside", "for", "about", "is", "as", "off", "off of"}
builtin_props#59r#2
list of 9{"name", "r", "w", "f", "programmer", "wizard", "owner", "location", "contents"}
error_names#59rc#36
list of 16{"E_NONE", "E_TYPE", "E_DIV", "E_PERM", "E_PROPNF", "E_VERBNF", "E_VARNF", "E_INVIND", "E_RECMOVE", "E_MAXREC", "E_RANGE", "E_ARGS", "E_NACC", "E_INVARG", "E_QUOTA", "E_FLOAT"}
error_list#59rc#36
list of 16{E_NONE, E_TYPE, E_DIV, E_PERM, E_PROPNF, E_VERBNF, E_VARNF, E_INVIND, E_RECMOVE, E_MAXREC, E_RANGE, E_ARGS, E_NACC, E_INVARG, E_QUOTA, E_FLOAT}
prepositions#59rc#36
list of 15{"with/using", "at/to", "in front of", "in/inside/into", "on top of/on/onto/upon", "out of/from inside/from", "over", "through", "under/underneath/beneath", "behind", "beside", "for/about", "is", "as", "off/off of"}
help_msg#79rc#36
list of 65{"parse_propref(\"foo.bar\") => {\"foo\",\"bar\"} (or 0 if arg. isn't a property ref.)", "parse_verbref(\"foo:bar\") => {\"foo\",\"bar\"} (or 0 if arg. isn't a verb ref.)", "parse_argspec(\"any\",\"in\",\"front\",\"of\",\"this\",\"baz\"...)", " => {{\"any\", \"in front of\", \"this\"},{\"baz\"...}} ", " (or string if args don't parse)", "", "toint(string) => integer (or E_TYPE if string is not a integer)", "toobj(string) => object (or E_TYPE if string is not an object)", "toerr(number or string) => error value (or 1 if out of range or unrecognized)", "error_name(error value) => name of error (e.g., error_name(E_PERM) => \"E_PERM\")", "", "verb_perms() => the current task_perms (as set by set_task_perms()).", "verb_location() => the object where the current verb is defined.", "verb_frame() => callers()-style frame for the current verb.", "verb_all_frames() => entire callers() stack including current verb.", "verb_usage([object,verbname]) => returns first line of verb doc, usually usage", "verb_documentation([object,verbname]) => documentation at beginning of", " verb code, if any -- default is the calling verb", "set_verb_documentation(object,verbname,text) => sets text at beginning of verb", "", " Preposition routines", "", "prepositions() => full list of prepostions", "full_prep (\"in\") => \"in/inside/into\"", "short_prep(\"into\") => \"in\"", "short_prep(\"in/inside/into\") => \"in\"", "get_prep (\"off\", \"of\", \"the\", \"table\") => {\"off of\", \"the\", \"table\"}", "", " Verb routines", "", "verbname_match (fullname,name) => can `name' be used to call `fullname'", "find_verb_named (object,name[,n]) => verb number or 0 if not found", "find_last_verb_named (object,name[,n]) => verb number of last verb match", "find_callable_verb_named (object,name[,n]) => verb number or 0 if not found", "find_verbs_containing (pattern[,object|objlist]) => does work for @grep", "find_verbs_matching (pattern[,object|objlist]) => does work for @egrep", "move_verb (from obj,name,to obj[,newname]) => move a verb from object to object", "", "move_prop (from obj,name,to obj[,newname]) => move a property to another object", "", " Verbs that do the actual dirty work for command lines verbs:", "", "@show => show_object (object)", " show_property(object,propname)", " show_verbdef (object,verbname)", "explain_syntax => explain_verb_syntax(thisname,verbname,@verbargs)", "eval*-d => eval_d(code)", "help => help_db_list([player])", " help_db_search(string topic, dblist)", "@who => show_who_listing(players [,more_players])", "@check-full => display_callers([callers() output])", "@dump => dump_preamble(object)", " => dump_properties(object, create_flag)", " => dump_verbs(object, create_flag)", "", " Random but useful verbs", "", "verb_or_property(object,name[,@args]) => result of verb or property call,", " or E_PROPNF", "corify_object(object) => if the object is corified, returns $<name>", "task_valid(INT task_id) => returns true if task_id is currently running.", "task_owner(INT task_id) => returns owner of task_id, if running", "owns_task(OBJ who,NUM task_id) => returns whether who owns task_id (if running)", "argstr(verb,args[,argstr] => returns a corrected argstr (see full verb help)", "substitute(string,subs) => subs in form {{\"target\", \"sub\"}, {...}, ...}"}
key#1c#36<clear>
aliases#1rc#36{"code utilities", "code utils"}
description#1rc#36{"This is the code utilities utility package. See `help $code_utils' for more details."}
object_size#1r#36{66113, -1090650497}

Ancestry

Ancestors (nearest first): #79 Generic Utilities Package#1 Root Class

Children: none

Call graph

calls n59_0 #59:eval_d n38_4 #38:bad_eval n59_0->n38_4 n59_50 #59:eval_d_util n59_0->n59_50 n59_5 #59:show_object n6_10 #6:notify n59_5->n6_10 n52_1 #52:all_properties n59_5->n52_1 n59_6 #59:show_property n59_6->n6_10 n20_48 #20:print n59_6->n20_48 n59_7 #59:show_verbdef n59_7->n6_10 n52_2 #52:has_verb n59_7->n52_2 n59_8 #59:explain_verb_syntax n59_17 #59:short_prep n59_8->n59_17 n59_20 #59:_fix_preps n59_17->n59_20 n59_11 #59:verb_documentation n38_0 #38:eval n59_11->n38_0 n59_12 #59:set_verb_documentation n59_12->n20_48 n59_12->n59_11 n59_15 #59:parse_argspec n59_19 #59:get_prep n59_15->n59_19 n59_16 #59:prepositions n59_16->n59_20 n20_38 #20:explode n59_20->n20_38 n55_0 #55:make n59_20->n55_0 n59_18 #59:full_prep n59_18->n59_20 n59_21 #59:find_verb_named n59_40 #59:verbname_match n59_21->n59_40 n59_22 #59:find_last_verb_named n59_22->n59_40 n59_23 #59:find_callable_verb_named n59_23->n59_40 n59_25 #59:find_verbs_containing n59_25->n6_10 n59_26 #59:_find_verbs_containing n59_25->n59_26 n56_7 #56:running_out_of_time n59_25->n56_7 n59_26->n6_10 n59_26->n56_7 n52_29 #52:accessible_verbs n59_26->n52_29 n59_29 #59:_grep_verb_code n59_26->n59_29 n59_29->n6_10 n59_27 #59:find_verbs_matching n59_27->n6_10 n59_27->n56_7 n59_28 #59:_find_verbs_matching n59_27->n59_28 n59_28->n6_10 n59_28->n56_7 n59_28->n52_29 n59_30 #59:_egrep_verb_code n59_28->n59_30 n59_32 #59:help_db_list n52_6 #52:ancestors n59_32->n52_6 n59_37 #59:task_valid n55_16 #55:slice n59_37->n55_16 n59_38 #59:task_owner n55_17 #55:assoc n59_38->n55_17 n59_39 #59:argstr n20_39 #20:words n59_39->n20_39 n20_40 #20:word_start n59_39->n20_40 n59_41 #59:substitute n59_35 #59:inside_quotes n59_41->n59_35 n59_42 #59:show_who_listing n59_42->n56_7 n55_23 #55:sort_alist n59_42->n55_23 n20_71 #20:redirect_ansi n59_42->n20_71

Showing 48 of 71 verbs; 23 not shown.

Source

eval_d

Spec any any anyFlags rxOwner #2Definer #59

Referenced by

Source

1":eval_d(code...) => {compiled?,result}";
2"This works exactly like the builtin eval() except that the code is evaluated ";
3"as if the d flag were unset.";
4code = {"set_verb_code(this,\"eval_d_util\",{\"\\\"Do not remove this verb!  This is an auxiliary verb for :eval_d().\\\";\"});", "dobj=iobj=this=#-1;", "dobjstr=iobjstr=prepstr=argstr=verb=\"\";", tostr("caller=", caller, ";"), "set_task_perms(caller_perms());", @args};
5if (!caller_perms().programmer)
6return E_PERM;
7elseif ((caller_perms() == $no_one) && $no_one:bad_eval(tostr(@args)))
8return E_PERM;
9elseif (svc = set_verb_code(this, "eval_d_util", code))
10lines = {};
11for line in (svc)
12if ((index(line, "Line ") == 1) && (n = toint(line[6..(colon = index(line + ":", ":")) - 1])))
13lines = {@lines, tostr("Line ", n - 5, line[colon..$])};
14else
15lines = {@lines, line};
16endif
17endfor
18return {0, lines};
19else
20set_task_perms(caller_perms());
21return {1, this:eval_d_util()};
22endif

toint tonum

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":toint(STR)";
2"=> toint(s) if STR is numeric";
3"=> E_TYPE if it isn't";
4return match(s = args[1], "^ *[-+]?[0-9]+ *$") ? toint(s) | E_TYPE;

toobj

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":toobj(objectid as string) => objectid";
2return match(s = args[1], "^ *#[-+]?[0-9]+ *$") ? toobj(s) | E_TYPE;

toerr

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1"toerr(n), toerr(\"E_FOO\"), toerr(\"FOO\") => E_FOO.";
2if (typeof(s = args[1]) != STR)
3n = toint(s) + 1;
4if (n > length(this.error_list))
5return 1;
6endif
7elseif (!(n = (s in this.error_names) || (("E_" + s) in this.error_names)))
8return 1;
9endif
10return this.error_list[n];

error_name

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1"error_name(E_FOO) => \"E_FOO\"";
2return toliteral(@args);
3return this.error_names[toint(args[1]) + 1];

show_object

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1set_task_perms(caller_perms());
2{object, ?what = {"props", "verbs"}} = args;
3player:notify(tostr("Object ID:  ", object));
4player:notify(tostr("Name:       ", object.name));
5names = {"Parent", "Location", "Owner"};
6vals = {parent(object), object.location, object.owner};
7for i in [1..length(vals)]
8if (!valid(vals[i]))
9val = "*** NONE ***";
10else
11val = ((vals[i].name + " (") + tostr(vals[i])) + ")";
12endif
13player:notify(tostr(names[i], ":      "[1..12 - length(names[i])], val));
14endfor
15line = "Flags:     ";
16if (is_player(object))
17line = line + " player";
18endif
19for flag in ({"programmer", "wizard", "r", "w", "f"})
20if (object.(flag))
21line = (line + " ") + flag;
22endif
23endfor
24player:notify(line);
25if (player.programmer && ((player.wizard || (player == object.owner)) || object.r))
26if (("verbs" in what) && (vs = verbs(object)))
27player:notify("Verb definitions:");
28for v in (vs)
29(ticks_left() < 4000) && suspend(0);
30player:notify(tostr("    ", v));
31endfor
32endif
33if ("props" in what)
34if (ps = properties(object))
35player:notify("Property definitions:");
36for p in (ps)
37(ticks_left() < 4000) && suspend(0);
38player:notify(tostr("    ", p));
39endfor
40endif
41all_props = $object_utils:all_properties(object);
42if (all_props != {})
43player:notify("Properties:");
44for p in (all_props)
45(ticks_left() < 4000) && suspend(0);
46strng = `toliteral(object.(p)) ! E_PERM => "(Permission denied.)"';
47player:notify(tostr("    ", p, ": ", strng));
48endfor
49endif
50endif
51elseif (player.programmer)
52player:notify("** Can't list properties or verbs: permission denied.");
53endif
54if (object.contents)
55player:notify("Contents:");
56for o in (object.contents)
57(ticks_left() < 4000) && suspend(0);
58player:notify(tostr("    ", o.name, " (", o, ")"));
59endfor
60endif

show_property

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1set_task_perms(caller_perms());
2{object, pname} = args;
3if (pname in this.builtin_props)
4player:notify(tostr(object, ".", pname));
5player:notify("Built-in property.");
6else
7try
8{owner, perms} = property_info(object, pname);
9except error (ANY)
10player:notify(error[2]);
11return;
12endtry
13player:notify(tostr(object, ".", pname));
14player:notify(tostr("Owner:        ", valid(owner) ? tostr(owner.name, " (", owner, ")") | "*** NONE ***"));
15player:notify(tostr("Permissions:  ", perms));
16endif
17player:notify(tostr("Value:        ", $string_utils:print(object.(pname))));

show_verbdef

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1set_task_perms(caller_perms());
2{object, vname} = args;
3if (!(hv = $object_utils:has_verb(object, vname)))
4player:notify("That object does not define that verb.");
5return;
6elseif (hv[1] != object)
7player:notify(tostr("Object ", object, " does not define that verb, but its ancestor ", hv[1], " does."));
8object = hv[1];
9endif
10try
11{owner, perms, names} = verb_info(object, vname);
12except error (ANY)
13player:notify(error[2]);
14return;
15endtry
16arg_specs = verb_args(object, vname);
17player:notify(tostr(object, ":", names));
18player:notify(tostr("Owner:            ", valid(owner) ? tostr(owner.name, " (", owner, ")") | "*** NONE ***"));
19player:notify(tostr("Permissions:      ", perms));
20player:notify(tostr("Direct Object:    ", arg_specs[1]));
21player:notify(tostr("Preposition:      ", arg_specs[2]));
22player:notify(tostr("Indirect Object:  ", arg_specs[3]));

explain_verb_syntax

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1if (args[4..5] == {"none", "this"})
2return 0;
3endif
4{thisobj, verb, adobj, aprep, aiobj} = args;
5prep_part = (aprep == "any") ? "to" | this:short_prep(aprep);
6".........`any' => `to' (arbitrary),... `none' => empty string...";
7if ((adobj == "this") && (dobj == thisobj))
8dobj_part = dobjstr;
9iobj_part = ((!prep_part) || (aiobj == "none")) ? "" | ((aiobj == "this") ? dobjstr | iobjstr);
10elseif ((aiobj == "this") && (iobj == thisobj))
11dobj_part = (adobj == "any") ? dobjstr | ((adobj == "this") ? iobjstr | "");
12iobj_part = iobjstr;
13elseif (!("this" in args[3..5]))
14dobj_part = (adobj == "any") ? dobjstr | "";
15iobj_part = (prep_part && (aiobj == "any")) ? iobjstr | "";
16else
17return 0;
18endif
19return tostr(verb, dobj_part ? " " + dobj_part | "", prep_part ? " " + prep_part | "", iobj_part ? " " + iobj_part | "");

verb_p*erms verb_permi*ssions

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1"returns the permissions of the current verb (either the owner or the result of the most recent set_task_perms()).";
2return caller_perms();

verb_loc*ation

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

none

Source

1"returns the object where the current verb is defined.";
2return callers()[1][4];

verb_documentation

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":verb_documentation([object,verbname]) => documentation at beginning of verb code, if any";
2"default is the calling verb";
3set_task_perms(caller_perms());
4c = callers()[1];
5{?object = c[4], ?vname = c[2]} = args;
6try
7code = verb_code(object, vname);
8except error (ANY)
9return error[2];
10endtry
11doc = {};
12for line in (code)
13if (match(line, "^\"%([^\\\"]%|\\.%)*\";$"))
14"... now that we're sure `line' is just a string, eval() is safe...";
15doc = {@doc, $no_one:eval("; return " + line)[2]};
16else
17return doc;
18endif
19endfor
20return doc;

set_verb_documentation

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":set_verb_documentation(object,verbname,text)";
2"  changes documentation at beginning of verb code";
3"  text is either a string or a list of strings";
4"  returns a non-1 value if anything bad happens...";
5set_task_perms(caller_perms());
6{object, vname, text} = args;
7if (typeof(code = `verb_code(object, vname) ! ANY') == ERR)
8return code;
9elseif (typeof(vd = $code_utils:verb_documentation(object, vname)) == ERR)
10return vd;
11elseif (!(typeof(text) in {LIST, STR}))
12return E_INVARG;
13else
14newdoc = {};
15for l in ((typeof(text) == LIST) ? text | {text})
16if (typeof(l) != STR)
17return E_INVARG;
18endif
19newdoc = {@newdoc, $string_utils:print(l) + ";"};
20endfor
21if (ERR == typeof(svc = `set_verb_code(object, vname, {@newdoc, @code[length(vd) + 1..$]}) ! ANY'))
22"... this shouldn't happen.  I'm not setting this code -d just yet...";
23return svc;
24else
25return 1;
26endif
27endif

parse_propref

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1"$code_utils:parse_propref(string)";
2"Parses string as a MOO-code property reference, returning {object-string, prop-name-string} for a successful parse and false otherwise.  It always returns the right object-string to pass to, for example, this-room:match_object.";
3s = args[1];
4if (dot = index(s, "."))
5object = s[1..dot - 1];
6prop = s[dot + 1..$];
7if ((object == "") || (prop == ""))
8return 0;
9elseif (object[1] == "$")
10object = `#0.(object[2..$]) ! ANY';
11if (typeof(object) != OBJ)
12return 0;
13endif
14object = tostr(object);
15endif
16elseif (index(s, "$") == 1)
17object = "#0";
18prop = s[2..$];
19else
20return 0;
21endif
22return {object, prop};

parse_verbref

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1"$code_utils:parse_verbref(string)";
2"Parses string as a MOO-code verb reference, returning {object-string, verb-name-string} for a successful parse and false otherwise.  It always returns the right object-string to pass to, for example, this-room:match_object().";
3s = args[1];
4if (colon = index(s, ":"))
5object = s[1..colon - 1];
6verbname = s[colon + 1..$];
7if (!(object && verbname))
8return 0;
9elseif (object[1] == "$")
10pname = object[2..$];
11if ((!(pname in properties(#0))) || (typeof(object = #0.(pname)) != OBJ))
12return 0;
13endif
14object = tostr(object);
15endif
16return {object, verbname};
17else
18return 0;
19endif

parse_argspec

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":parse_arg_spec(@args)";
2"  attempts to parse the given sequence of args into a verb_arg specification";
3"returns {verb_args,remaining_args} if successful.";
4"  e.g., :parse_arg_spec(\"this\",\"in\",\"front\",\"of\",\"any\",\"foo\"..)";
5"           => {{\"this\",\"in front of\",\"any\"},{\"foo\"..}}";
6"returns a string error message if parsing fails.";
7nargs = length(args);
8if (nargs < 1)
9return {{}, {}};
10elseif ((ds = args[1]) == "tnt")
11return {{"this", "none", "this"}, listdelete(args, 1)};
12elseif (!(ds in {"this", "any", "none"}))
13return tostr("\"", ds, "\" is not a valid direct object specifier.");
14elseif ((nargs < 2) || (args[2] in {"none", "any"}))
15verbargs = args[1..min(3, nargs)];
16rest = args[4..nargs];
17elseif (!(gp = $code_utils:get_prep(@args[2..nargs]))[1])
18return tostr("\"", args[2], "\" is not a valid preposition.");
19else
20verbargs = {ds, @gp[1..min(2, nargs = length(gp))]};
21rest = gp[3..nargs];
22endif
23if ((length(verbargs) >= 3) && (!(verbargs[3] in {"this", "any", "none"})))
24return tostr("\"", verbargs[3], "\" is not a valid indirect object specifier.");
25endif
26return {verbargs, rest};

prepositions

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1if (server_version() != this._version)
2this:_fix_preps();
3endif
4return this.prepositions;

short_prep

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":short_prep(p) => shortest preposition equivalent to p";
2"p may be a single word or one of the strings returned by verb_args().";
3if (server_version() != this._version)
4this:_fix_preps();
5endif
6word = args[1];
7word = word[1..index(word + "/", "/") - 1];
8if (p = word in this._other_preps)
9return this._short_preps[this._other_preps_n[p]];
10elseif (word in this._short_preps)
11return word;
12else
13return "";
14endif

full_prep

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1if (server_version() != this._version)
2this:_fix_preps();
3endif
4prep = args[1];
5if (p = prep in this._short_preps)
6return this.prepositions[p];
7elseif (p = prep in this._other_preps)
8return this.prepositions[this._other_preps_n[p]];
9else
10return "";
11endif

get_prep

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":get_prep(@args) extracts the prepositional phrase from the front of args, returning a list consisting of the preposition (or \"\", if none) followed by the unused args.";
2":get_prep(\"in\",\"front\",\"of\",...) => {\"in front of\",...}";
3":get_prep(\"inside\",...)          => {\"inside\",...}";
4":get_prep(\"frabulous\",...}       => {\"\", \"frabulous\",...}";
5prep = "";
6allpreps = {@this._short_preps, @this._other_preps};
7rest = 1;
8for i in [1..length(args)]
9accum = (i == 1) ? args[1] | tostr(accum, " ", args[i]);
10if (accum in allpreps)
11prep = accum;
12rest = i + 1;
13endif
14if (!(accum in this._multi_preps))
15return {prep, @args[rest..$]};
16endif
17endfor
18return {prep, @args[rest..$]};

_fix_preps

Spec this at/to thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":_fix_preps() updates the properties on this having to do with prepositions.";
2"_fix_preps should be called whenever we detect that a new server version has been installed.";
3orig_args = verb_args(this, verb);
4multis = nothers = others = shorts = longs = {};
5i = 0;
6while (typeof(`set_verb_args(this, verb, {"this", tostr(i), "this"}) ! ANY') != ERR)
7l = verb_args(this, verb)[2];
8all = $string_utils:explode(l, "/");
9s = all[1];
10for p in (listdelete(all, 1))
11if (length(p) <= length(s))
12s = p;
13endif
14endfor
15for p in (all)
16while (j = rindex(p, " "))
17multis = {p = p[1..j - 1], @multis};
18endwhile
19endfor
20longs = {@longs, l};
21shorts = {@shorts, s};
22others = {@others, @setremove(all, s)};
23nothers = {@nothers, @$list_utils:make(length(all) - 1, length(shorts))};
24i = i + 1;
25endwhile
26set_verb_args(this, verb, orig_args);
27this.prepositions = longs;
28this._short_preps = shorts;
29this._other_preps = others;
30this._other_preps_n = nothers;
31this._multi_preps = multis;
32this._version = server_version();
33return;

find_verb_named

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":find_verb_named(object,name[,n])";
2"  returns the *number* of the first verb on object matching the given name.";
3"  optional argument n, if given, starts the search with verb n,";
4"  causing the first n verbs (1..n-1) to be ignored.";
5"  0 is returned if no verb is found.";
6"  This routine does not find inherited verbs.";
7{object, name, ?start = 1} = args;
8for i in [start..length(verbs(object))]
9verbinfo = verb_info(object, i);
10if (this:verbname_match(verbinfo[3], name))
11return i;
12endif
13endfor
14return 0;

find_last_verb_named

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":find_last_verb_named(object,name[,n])";
2"  returns the *number* of the last verb on object matching the given name.";
3"  optional argument n, if given, starts the search with verb n-1,";
4"  causing verbs (n..length(verbs(object))) to be ignored.";
5"  -1 is returned if no verb is found.";
6"  This routine does not find inherited verbs.";
7{object, name, ?last = -1} = args;
8if (last < 0)
9last = length(verbs(object));
10endif
11for i in [0..last - 1]
12verbinfo = verb_info(object, last - i);
13if (this:verbname_match(verbinfo[3], name))
14return last - i;
15endif
16endfor
17return -1;

find_callable_verb_named

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":find_callable_verb_named(object,name[,n])";
2"  returns the *number* of the first verb on object that matches the given";
3"  name and has the x flag set.";
4"  optional argument n, if given, starts the search with verb n,";
5"  causing the first n verbs (0..n-1) to be ignored.";
6"  0 is returned if no verb is found.";
7"  This routine does not find inherited verbs.";
8{object, name, ?start = 1} = args;
9for i in [start..length(verbs(object))]
10verbinfo = verb_info(object, i);
11if (index(verbinfo[2], "x") && this:verbname_match(verbinfo[3], name))
12return i;
13endif
14endfor
15return 0;

verbname_match(new)

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

none

Source

1":verbname_match(fullverbname,name) => TRUE iff `name' is a valid name for a verb with the given `fullname'";
2verblist = (" " + args[1]) + " ";
3if (index(verblist, (" " + (name = args[2])) + " ") && (!match(name, "[ *]")))
4"Note that if name has a * or a space in it, then it can only match one of the * verbnames";
5return 1;
6else
7namelen = length(name);
8while (m = match(verblist, "[^ *]*%(%*%)[^ ]*"))
9vlast = m[2];
10if ((namelen >= (m[3][1][1] - m[1])) && ((!(v = strsub(verblist[m[1]..vlast], "*", ""))) || (index(v, (verblist[vlast] == "*") ? name[1..min(namelen, length(v))] | name) == 1)))
11return 1;
12endif
13verblist = verblist[vlast + 1..$];
14endwhile
15endif
16return 0;

find_verbs_containing

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1"$code_utils:find_verbs_containing(pattern[,object|object-list])";
2"";
3"Print (to player) the name and owner of every verb in the database whose code contains PATTERN as a substring.  Optional second argument limits the search to the specified object or objects.";
4"";
5"Because it searches the entire database, this function may suspend the task several times before returning.";
6"";
7set_task_perms(caller_perms());
8"... puts the task in a player's own job queue and prevents someone from learning about verbs that are otherwise unreadable to him/her.";
9{pattern, ?where = 0} = args;
10count = 0;
11if (typeof(where) == INT)
12for o in [toobj(where)..max_object()]
13if (valid(o))
14count = count + this:_find_verbs_containing(pattern, o);
15endif
16if ($command_utils:running_out_of_time())
17player:notify(tostr("...", o));
18suspend(0);
19endif
20endfor
21elseif (typeof(where) == LIST)
22for o in (where)
23count = count + this:_find_verbs_containing(pattern, o);
24endfor
25else
26"...typeof(where) == OBJ...";
27count = this:_find_verbs_containing(pattern, where);
28endif
29player:notify("");
30player:notify(tostr("Total: ", count, " verbs."));

_find_verbs_containing

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":_find_verbs_containing(pattern,object)";
2"number of verbs in object with code having a line containing pattern";
3"prints verbname and offending line to player";
4set_task_perms(caller_perms());
5{pattern, o} = args;
6count = 0;
7verbs = $object_utils:accessible_verbs(o);
8if (typeof(verbs) == ERR)
9return player:notify(tostr("verbs(", o, ") => ", e[2]));
10endif
11for vnum in [1..length(verbs)]
12if (l = this:_grep_verb_code(pattern, o, vnum))
13owner = verb_info(o, vnum)[1];
14player:notify(tostr(o, ":", verbs[vnum], " [", valid(owner) ? owner.name | "Recycled Player", " (", owner, ")]:  ", l));
15count = count + 1;
16endif
17if ($command_utils:running_out_of_time())
18player:notify(tostr("...", o));
19suspend(0);
20endif
21endfor
22return count;

find_verbs_matching

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1"$code_utils:find_verbs_matching(pattern[,object|object-list])";
2"";
3"Print (to player) the name and owner of every verb in the database whose code has a substring matches the regular expression PATTERN.  Optional second argument limits the search to the specified object or objects.";
4"";
5"Because it searches the entire database, this function may suspend the task several times before returning.";
6"";
7set_task_perms(caller_perms());
8"... puts the task in a player's own job queue and prevents someone from learning about verbs that are otherwise unreadable to him/her.";
9{pattern, ?where = 0} = args;
10count = 0;
11if (typeof(where) == INT)
12for o in [toobj(where)..max_object()]
13if (valid(o))
14count = count + this:_find_verbs_matching(pattern, o);
15endif
16if ($command_utils:running_out_of_time())
17player:notify(tostr("...", o));
18suspend(0);
19endif
20endfor
21elseif (typeof(where) == LIST)
22for o in (where)
23count = count + this:_find_verbs_matching(pattern, o);
24endfor
25else
26count = this:_find_verbs_matching(pattern, where);
27endif
28player:notify("");
29player:notify(tostr("Total: ", count, " verbs."));

_find_verbs_matching

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":_find_verbs_matching(regexp,object[,casematters])";
2"number of verbs in object with code having a line matching regexp";
3"prints verbname and offending line to player";
4set_task_perms(caller_perms());
5{pattern, o, ?casematters = 0} = args;
6count = 0;
7verbs = $object_utils:accessible_verbs(o);
8if (typeof(verbs) == ERR)
9return player:notify(tostr("verbs(", o, ") => ", e[2]));
10endif
11for vnum in [1..length(verbs)]
12if (l = this:_egrep_verb_code(pattern, o, vnum, casematters))
13owner = verb_info(o, vnum)[1];
14player:notify(tostr(o, ":", verbs[vnum], " [", valid(owner) ? owner.name | "Recycled Player", " (", owner, ")]:  ", l));
15count = count + 1;
16endif
17if ($command_utils:running_out_of_time())
18player:notify(tostr("...", o));
19suspend(0);
20endif
21endfor
22return count;

_grep_verb_code

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":_grep_verb_code(pattern,object,verbname) => line number or 0";
2"  returns line number on which pattern occurs in code for object:verbname";
3set_task_perms(caller_perms());
4pattern = args[1];
5vc = `verb_code(@listdelete(args, 1)) ! ANY';
6if ((typeof(vc) == ERR) || (!index(tostr(@vc), pattern)))
7return 0;
8else
9((seconds_left() < 2) && (!suspend(0))) && player:notify(tostr("...", args[2]));
10for line in (vc)
11if (index(line, pattern))
12return line;
13endif
14endfor
15return 0;
16endif

_egrep_verb_code

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":_egrep_verb_code(regexp,object,verbname[,casematters]) => 0 or line number";
2"  returns line number of first line matching regexp in object:verbname code";
3set_task_perms(caller_perms());
4{pattern, object, vname, ?casematters = 0} = args;
5for line in (vc = `verb_code(object, vname) ! ANY => {}')
6try
7if (match(line, pattern, casematters))
8return line;
9endif
10except (E_INVARG)
11raise(E_INVARG, "Malformed regular expression.");
12endtry
13endfor
14return 0;

_parse_audit_args

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1"Parse [from <start>] [to <end>] [for <name>].";
2"Takes a series of strings, most likely @args with dobjstr removed.";
3"Returns a list {INT start, INT end, STR name}, or {} if there is an error.";
4fail = length(args) % 2;
5start = 0;
6end = toint(max_object());
7match = "";
8while (args && (!fail))
9prep = args[1];
10if (prep == "from")
11if ((start = player.location:match_object(args[2])) >= #0)
12start = toint(start);
13else
14start = toint(args[2]);
15endif
16elseif (prep == "to")
17if ((end = player.location:match_object(args[2])) >= #0)
18end = toint(end);
19else
20end = toint(args[2]);
21endif
22elseif (prep == "for")
23match = args[2];
24else
25fail = 1;
26endif
27args = args[3..length(args)];
28endwhile
29return fail ? {} | {start, end, match};

help_db_list

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":help_db_list([player]) => list of help dbs";
2"in the order that they are consulted by player";
3{?who = player} = args;
4olist = {who, @$object_utils:ancestors(who)};
5if (valid(who.location))
6olist = {@olist, who.location, @$object_utils:ancestors(who.location)};
7endif
8dbs = {};
9for o in (olist)
10h = `o.help ! ANY => 0';
11if (typeof(h) == OBJ)
12h = {h};
13endif
14if (typeof(h) == LIST)
15for db in (h)
16if ((typeof(db) == OBJ) && (valid(db) && (!(db in dbs))))
17dbs = {@dbs, db};
18endif
19endfor
20endif
21endfor
22return setadd(dbs, $help);

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":help_db_search(string,dblist)";
2"  searches each of the help db's in dblist for a topic matching string.";
3"  Returns  {db,topic}  or  {$ambiguous_match,{topic...}}  or {}";
4{what, dblist} = args;
5topics = {};
6help = 1;
7for db in (dblist)
8(ticks_left() < 4000) && suspend(0);
9if ({what} == (ts = `db:find_topics(what) ! ANY => 0'))
10return {db, ts[1]};
11elseif (ts && (typeof(ts) == LIST))
12if (help)
13help = db;
14endif
15for t in (ts)
16topics = setadd(topics, t);
17endfor
18endif
19endfor
20if (length(topics) > 1)
21return {$ambiguous_match, topics};
22elseif (topics)
23return {help, topics[1]};
24else
25return {};
26endif

corify_object

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":corify_object(object)  => string representing object";
2"  usually just returns tostr(object), but in the case of objects that have";
3"  corresponding #0 properties, return the appropriate $-string.";
4object = args[1];
5"Just in case #0 is !r on some idiot core.";
6for p in (`properties(#0) ! ANY => {}')
7"And if for some reason, some #0 prop is !r.";
8if (`#0.(p) ! ANY' == object)
9return "$" + p;
10endif
11endfor
12return tostr(object);

inside_quotes

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1"See if the end of the string passed as args[1] ends 'inside' a doublequote.  Used by $code_utils:substitute.";
2{string} = args;
3quoted = 0;
4while (i = index(string, "\""))
5if ((!quoted) || ((i == 1) || (string[i - 1] != "\\")))
6quoted = !quoted;
7endif
8string = string[i + 1..$];
9endwhile
10return quoted;

verb_or_property

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1"verb_or_property(<obj>, <name> [, @<args>])";
2"Looks for a callable verb or property named <name> on <obj>.";
3"If <obj> has a callable verb named <name> then return <obj>:(<name>)(@<args>).";
4"If <obj> has a property named <name> then return <obj>.(<name>).";
5"Otherwise return E_PROPNF, or E_PERM if you don't have permission to read the property.";
6set_task_perms(caller_perms());
7{object, name, @rest} = args;
8return `object:(name)(@rest) ! E_VERBNF, E_INVIND => `object.(name) ! ANY'';

task_valid

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1"task_valid(INT id)";
2"Return true iff there is currently a valid task with the given id.";
3set_task_perms($no_one);
4{id} = args;
5t = $list_utils:slice(queued_tasks(), 1);
6return ((id == task_id()) || (id in t)) || (E_PERM == `kill_task(id) ! ANY');

task_owner

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":task_owner(INT task_id) => returns the owner of the task belonging to the id.";
2if (a = $list_utils:assoc(args[1], queued_tasks()))
3return a[5];
4else
5return E_INVARG;
6endif

argstr

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":argstr(verb,args[,argstr]) => what argstr should have been.  ";
2"Recall that the command line is parsed into a sequence of words; `verb' is";
3"assigned the first word, `args' is assigned the remaining words, and argstr";
4"is assigned a substring of the command line, which *should* be the one";
5"starting first nonblank character after the verb, but is instead (because";
6"the parser is BROKEN!) the one starting with the first nonblank character";
7"after the first space in the line, which is not necessarily after the verb.";
8"Clearly, if the verb contains spaces --- which can happen if you use";
9"backslashes and quotes --- this loses, and argstr will then erroneously";
10"have extra junk at the beginning.  This verb, given verb, args, and the";
11"actual argstr, returns what argstr should have been.";
12verb = args[1];
13argstr = {@args, argstr}[3];
14n = length(args = args[2]);
15if (!index(verb, " "))
16return argstr;
17elseif (!args)
18return "";
19endif
20"space in verb => two possible cases:";
21"(1) first space was not in a quoted string.";
22"    first word of argstr == rest of verb unless verb ended on this space.";
23if ((nqargs = $string_utils:words(argstr)) == args)
24return argstr;
25elseif (((nqn = length(nqargs)) == (n + 1)) && (nqargs[2..nqn] == args))
26return argstr[$string_utils:word_start(argstr)[2][1]..length(argstr)];
27else
28"(2) first space was in a quoted string.";
29"    argstr starts with rest of string";
30qs = $string_utils:word_start("\"" + argstr);
31return argstr[qs[(length(qs) - length(args)) + 1][1] - 1..length(argstr)];
32endif

verbname_match

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1":verbname_match(fullverbname,name) => TRUE iff `name' is a valid name for a verb with the given `fullname'";
2verblist = (" " + args[1]) + " ";
3if (index(verblist, (" " + (name = args[2])) + " ") && (!(index(name, "*") || index(name, " "))))
4"Note that if name has a * or a space in it, then it can only match one of the * verbnames";
5return 1;
6else
7namelen = length(name);
8while (star = index(verblist, "*"))
9vstart = rindex(verblist[1..star], " ") + 1;
10vlast = (vstart + index(verblist[vstart..$], " ")) - 2;
11if ((namelen >= (star - vstart)) && ((!(v = strsub(verblist[vstart..vlast], "*", ""))) || (index(v, (verblist[vlast] == "*") ? name[1..min(namelen, length(v))] | name) == 1)))
12return 1;
13endif
14verblist = verblist[vlast + 1..$];
15endwhile
16endif
17return 0;

substitute

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

Source

1"$code_utils:substitute(string,subs) => new line";
2"Subs are a list of lists, {{\"target\",\"sub\"},{...}...}";
3"Substitutes targets for subs in a delimited string fashion, avoiding substituting anything inside quotes, e.g. player:tell(\"don't sub here!\")";
4{s, subs} = args;
5lets = "abcdefghijklmnopqrstuvwxyz0123456789";
6for x in (subs)
7len = length(sub = x[1]);
8delimited = index(lets, sub[1]) && index(lets, sub[len]);
9prefix = "";
10while (i = index(s, sub))
11prefix = prefix + s[1..i - 1];
12if ((((prefix == "") || ((!delimited) || (!index(lets, prefix[$])))) && ((!delimited) || (((i + len) > length(s)) || (!index(lets, s[i + len]))))) && (!this:inside_quotes(prefix)))
13prefix = prefix + x[2];
14else
15prefix = prefix + s[i..(i + len) - 1];
16endif
17s = s[i + len..length(s)];
18endwhile
19s = prefix + s;
20endfor
21return s;

show_who_listing

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":show_who_listing(players[,more_players])";
2" prints a listing of the indicated players.";
3" For players in the first list, idle/connected times are shown if the player is logged in, otherwise the last_disconnect_time is shown.  For players in the second list, last_disconnect_time is shown, no matter whether the player is logged in.";
4{plist, ?more_plist = {}} = args;
5idles = itimes = offs = otimes = {};
6argstr = dobjstr = iobjstr = prepstr = "";
7for p in (more_plist)
8if (!valid(p))
9caller:notify(tostr(p, " <invalid>"));
10elseif (typeof(t = `p.last_disconnect_time ! E_PROPNF') == INT)
11if (!(p in offs))
12offs = {@offs, p};
13otimes = {@otimes, {-t, -t, p}};
14endif
15elseif (is_player(p))
16caller:notify(tostr(p.name, " (", p, ") ", (t == E_PROPNF) ? "is not a $player." | "has a garbled .last_disconnect_time."));
17else
18caller:notify(tostr(p.name, " (", p, ") is not a player."));
19endif
20endfor
21for p in (plist)
22if (p in offs)
23elseif (!valid(p))
24caller:notify(tostr(p, " <invalid>"));
25elseif (typeof(i = `idle_seconds(p) ! ANY') != ERR)
26if (!(p in idles))
27idles = {@idles, p};
28itimes = {@itimes, {i, connected_seconds(p), p}};
29endif
30elseif (typeof(t = `p.last_disconnect_time ! E_PROPNF') == INT)
31offs = {@offs, p};
32otimes = {@otimes, {-t, -t, p}};
33elseif (is_player(p))
34caller:notify(tostr(p.name, " (", p, ") not logged in.", (t == E_PROPNF) ? "  Not a $player." | "  Garbled .last_disconnect_time."));
35else
36caller:notify(tostr(p.name, " (", p, ") is not a player."));
37endif
38endfor
39if (!(idles || offs))
40return 0;
41endif
42idles = $list_utils:sort_alist(itimes);
43offs = $list_utils:sort_alist(otimes);
44"...";
45"... calculate widths...";
46"...";
47headers = {"Player name", @idles ? {"Connected", "Idle time"} | {"Last disconnect time", ""}, "Location"};
48total_width = `caller:linelen() ! ANY => 0' || 79;
49max_name = total_width / 4;
50name_width = length(headers[1]);
51names = locations = {};
52for lst in ({@idles, @offs})
53(ticks_left() < 5000) && suspend(0);
54p = lst[3];
55namestr = tostr(p.name[1..min(max_name, $)], " (", p, ")");
56name_width = max(length(namestr), name_width);
57names = {@names, namestr};
58if (typeof(wlm = `p.location:who_location_msg(p) ! ANY') != STR)
59wlm = valid(p.location) ? p.location.name | tostr("** Nowhere ** (", p.location, ")");
60endif
61locations = {@locations, wlm};
62endfor
63time_width = 3 + (offs ? 12 | length("59 minutes"));
64before = {0, w1 = 3 + name_width, w2 = w1 + time_width, w2 + time_width};
65"...";
66"...print headers...";
67"...";
68su = $string_utils;
69tell1 = headers[1];
70tell2 = su:space(tell1, "-");
71for j in [2..4]
72tell1 = su:left(tell1, before[j]) + headers[j];
73tell2 = su:left(tell2, before[j]) + su:space(headers[j], "-");
74endfor
75caller:notify(tell1[1..min($, total_width)]);
76caller:notify(tell2[1..min($, total_width)]);
77"...";
78"...print lines...";
79"...";
80active = 0;
81for i in [1..total = (ilen = length(idles)) + length(offs)]
82if (i <= ilen)
83lst = idles[i];
84if (lst[1] < (5 * 60))
85active = active + 1;
86endif
87l = {names[i], su:from_seconds(lst[2]), su:from_seconds(lst[1]), locations[i]};
88else
89lct = offs[i - ilen][3].last_connect_time;
90ldt = offs[i - ilen][3].last_disconnect_time;
91ctime = `caller:ctime(ldt) ! ANY => 0' || ctime(ldt);
92l = {names[i], (lct <= time()) ? ctime | "Never", "", locations[i]};
93if ((i == (ilen + 1)) && idles)
94caller:notify(su:space(before[2]) + "------- Disconnected -------");
95endif
96endif
97tell1 = l[1];
98for j in [2..4]
99tell1 = su:left(tell1, before[j]) + l[j];
100endfor
101caller:notify(tell1[1..min($, total_width)]);
102if ($command_utils:running_out_of_time())
103if ($login:is_lagging())
104"Check lag two ways---global lag, but we might still fail due to individual lag of the queue this runs in, so check again later.";
105caller:notify(tostr("Plus ", total - i, " other players (", total, " total; out of time and lag is high)."));
106return;
107endif
108now = time();
109suspend(0);
110if ((time() - now) > 10)
111caller:notify(tostr("Plus ", total - i, " other players (", total, " total; out of time and lag is high)."));
112return;
113endif
114endif
115endfor
116"...";
117"...epilogue...";
118"...";
119caller:notify("");
120if (total == 1)
121active_str = ", who has" + ((active == 1) ? "" | " not");
122else
123if (active == total)
124active_str = (active == 2) ? "s, both" | "s, all";
125elseif (active == 0)
126active_str = "s, none";
127else
128active_str = tostr("s, ", active);
129endif
130active_str = tostr(active_str, " of whom ha", (active == 1) ? "s" | "ve");
131endif
132caller:notify(tostr("Total: ", total, " player", active_str, " been active recently."));
133return total;

_egrep_verb_code_all

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":_egrep_verb_code_all(regexp,object,verbname) => list of lines number";
2"  returns list of all lines matching regexp in object:verbname code";
3set_task_perms(caller_perms());
4{pattern, object, vname} = args;
5lines = {};
6for line in (vc = `verb_code(object, vname, 1, 0) ! ANY => {}')
7if (match(line, pattern))
8lines = {@lines, line};
9endif
10endfor
11return lines;

_grep_verb_code_all

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":_grep_verb_code_all(pattern,object,verbname) => list of lines";
2"  returns list of lines on which pattern occurs in code for object:verbname";
3set_task_perms(caller_perms());
4{pattern, object, vname} = args;
5lines = {};
6for line in (vc = `verb_code(object, vname) ! ANY => {}')
7if (index(line, pattern))
8lines = {@lines, line};
9endif
10endfor
11return lines;

verb_usage

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":verb_usage([object,verbname]) => usage string at beginning of verb code, if any";
2"default is the calling verb";
3set_task_perms(caller_perms());
4c = callers()[1];
5{?object = c[4], ?vname = c[2]} = args;
6if (typeof(code = `verb_code(object, vname) ! ANY') == ERR)
7return code;
8else
9doc = {};
10indent = "^$";
11for line in (code)
12if (match(line, "^\"%([^\\\"]%|\\.%)*\";$"))
13"... now that we're sure `line' is just a string, eval() is safe...";
14e = $no_one:eval(line)[2];
15if (subs = match(e, "^%(%(Usage%|Syntax%): +%)%([^ ]+%)%(.*$%)"))
16"Server is broken, hence the next three lines:";
17if (subs[3][4][1] > subs[3][4][2])
18subs[3][4] = {0, -1};
19endif
20indent = ("^%(" + $string_utils:space(length(substitute("%1", subs)))) + " *%)%([^ ]+%)%(.*$%)";
21docverb = substitute("%3", subs);
22if (match(vname, "^[0-9]+$"))
23vname = docverb;
24endif
25doc = {@doc, (substitute("%1", subs) + vname) + substitute("%4", subs)};
26elseif (subs = match(e, indent))
27if (substitute("%3", subs) == docverb)
28doc = {@doc, (substitute("%1", subs) + vname) + substitute("%4", subs)};
29else
30doc = {@doc, e};
31endif
32elseif (indent)
33return doc;
34endif
35else
36return doc;
37endif
38endfor
39return doc;
40endif

verb_frame

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

none

Source

1"returns the callers() frame for the current verb.";
2return callers()[1];

verb_all_frames

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

none

Source

1"returns {this:verb_frame(), @callers()}.";
2return callers();

move_verb

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":move_verb(OBJ from, STR verb name, OBJ to, [STR new verb name]) -> Moves the specified verb from one object to another. Returns {OBJ, Full verb name} where the verb now resides if successful, error if not. To succeed, caller_perms() must control both objects and own the verb, unless called with wizard perms. Supplying a fourth argument moves the verb to a new name.";
2"Should handle verbnames with aliases and wildcards correctly.";
3who = caller_perms();
4{from, origverb, to, ?destverb = origverb} = args;
5if ((((typeof(from) != OBJ) || (typeof(to) != OBJ)) || (typeof(origverb) != STR)) || (typeof(destverb) != STR))
6"check this first so we can parse out long verb names next";
7return E_TYPE;
8endif
9origverb_first = strsub(origverb[1..index(origverb + " ", " ") - 1], "*", "") || "*";
10destverb_first = strsub(destverb[1..index(destverb + " ", " ") - 1], "*", "") || "*";
11if ((!valid(from)) || (!valid(to)))
12return E_INVARG;
13elseif ((from == to) && (destverb == origverb))
14"Moving same origverb onto the same object puts the verbcode in the wrong one. Just not allow";
15return E_NACC;
16elseif (((!$perm_utils:controls(who, from)) && (!from.w)) || ((!$perm_utils:controls(who, to)) && (!to.w)))
17"caller_perms() is not allowed to hack on either object in question";
18return E_PERM;
19elseif (!$object_utils:defines_verb(from, origverb_first))
20"verb is not defined on the from object";
21return E_VERBNF;
22elseif ((vinfo = verb_info(from, origverb_first)) && (!$perm_utils:controls(who, vinfo[1])))
23"caller_perms() is not permitted to add a verb with the existing verb owner";
24return E_PERM;
25elseif (!who.programmer)
26return E_PERM;
27else
28"we now know that the caller's perms control the objects or the objects are writable, and we know that the caller's perms control the prospective verb owner (by more traditional means)";
29vcode = verb_code(from, origverb_first);
30vargs = verb_args(from, origverb_first);
31vinfo[3] = (destverb == origverb) ? vinfo[3] | destverb;
32if (typeof(res = `add_verb(to, vinfo, vargs) ! ANY') == ERR)
33return res;
34else
35set_verb_code(to, destverb_first, vcode);
36delete_verb(from, origverb_first);
37return {to, vinfo[3]};
38endif
39endif

move_prop*erty

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":move_prop(OBJ from, STR prop name, OBJ to, [STR new prop name]) -> Moves the specified property and its contents from one object to another. Returns {OBJ, property name} where the property now resides if successful, error if not. To succeed, caller_perms() must control both objects and own the property, unless called with wizard perms. Supplying a fourth argument gives the property a new name on the new object.";
2who = caller_perms();
3{from, origprop, to, ?destprop = origprop} = args;
4if ((((typeof(from) != OBJ) || (typeof(to) != OBJ)) || (typeof(origprop) != STR)) || (typeof(destprop) != STR))
5return E_TYPE;
6elseif ((!valid(from)) || (!valid(to)))
7return E_INVARG;
8elseif ((from == to) && (destprop == origprop))
9"Moving same prop onto the same object puts the contents in the wrong one. Just not allow";
10return E_NACC;
11elseif (((!$perm_utils:controls(who, from)) && (!from.w)) || ((!$perm_utils:controls(who, to)) && (!to.w)))
12"caller_perms() is not allowed to hack on either object in question";
13return E_PERM;
14elseif (!$object_utils:defines_property(from, origprop))
15"property is not defined on the from object";
16return E_PROPNF;
17elseif ((pinfo = property_info(from, origprop)) && (!$perm_utils:controls(who, pinfo[1])))
18"caller_perms() is not permitted to add a property with the existing property owner";
19return E_PERM;
20elseif (!who.programmer)
21return E_PERM;
22else
23"we now know that the caller's perms control the objects or the objects are writable, and we know that the caller's perms control the prospective property owner (by more traditional means)";
24pdata = from.(origprop);
25pname = (destprop == origprop) ? origprop | destprop;
26if (typeof(res = `add_property(to, pname, pdata, pinfo) ! ANY') == ERR)
27return res;
28else
29delete_property(from, origprop);
30return {to, pname};
31endif
32endif

eval_d_util

Spec this none thisFlags rxOwner #2Definer #59

Referenced by

Source

1"Do not remove this verb!  This is an auxiliary verb for :eval_d().";

display_callers

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":display_callers([callers() style list]) - displays the output of the given argument, assumed to be a callers() output. See `help callers()' for details. Will use callers() explicitly if no argument is passed.";
2call = (caller_perms() == player) ? "notify_lines" | "tell_lines";
3player:(call)(this:callers_text(@args));

callers_text

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1":callers_text([callers() style list]) - returns the output of the given argument, assumed to be a callers() output. See `help callers()' for details. Will use callers() explicitly if no argument is passed.";
2linelen = min(player:linelen(), 200);
3text = {};
4su = $string_utils;
5lu = $list_utils;
6verbwidth = 0;
7{?match = callers(1)} = args;
8for verbitem in (lu:slice(match, 2))
9verbwidth = max(verbwidth, length(verbitem));
10endfor
11verbwidth = 3 + verbwidth;
12numwidth = ((linelen - verbwidth) / 4) - 1;
13widths = {numwidth, verbwidth, numwidth, numwidth, numwidth};
14top = l = between = "";
15for x in [1..5]
16top = (top + between) + su:left({"This", "Verb", "Permissions", "VerbLocation", "Player"}[x], -widths[x]);
17l = (l + between) + su:space(widths[x], "-");
18between = " ";
19endfor
20text = listappend(text, top);
21text = listappend(text, l);
22for line in (match)
23output = {};
24for bit in [1..5]
25(ticks_left() < 5000) && suspend(2);
26"bit == 2 below for verb: append line number.";
27output = {@output, su:left((typeof(word = line[bit]) == STR) ? (bit == 2) ? tostr(word, "(", `line[6] ! ANY => 0', ")") | word | tostr(word, "(", valid(word) ? lu:shortest({word.name, @word.aliases}) | ((word == $nothing) ? "invalid" | ((word == $ambiguous_match) ? "ambiguous match" | "Error")), ")"), -widths[bit]), " "};
28endfor
29text = listappend(text, su:trimr(tostr(@output)));
30endfor
31text = listappend(text, l);
32return text;

set_property_value set_verb_or_property

Spec this none thisFlags rxOwner #2Definer #59

Referenced by

none

Source

1":set_property_value(object, property, value)";
2" set_verb_or_property(same) -- similar to `verb_or_property'";
3"  -- attempts to set <object>.<property> to <value>.  If there exists <object>:set_<property>, then it is called and its returned value is returned.  If not, we try to set the property directly; the result of this is returned.";
4set_task_perms(caller_perms());
5if (length(args) != 3)
6return E_ARGS;
7elseif (typeof(o = args[1]) != OBJ)
8return E_INVARG;
9elseif (!$recycler:valid(o))
10return E_INVIND;
11elseif (typeof(p = args[2]) != STR)
12return E_INVARG;
13elseif ($object_utils:has_callable_verb(o, v = "set_" + p))
14return o:(v)(args[3]);
15else
16return o.(p) = args[3];
17endif

owns_task

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1"$code_utils:owns_task(who, task_id)";
2"The purpose of this is to be faster than $code_utils:task_owner(task_id) in those cases where you are interested in whether a certain person owns the task rather than in determining the owner of a task where you have no preconceived notion of the owner.";
3return $list_utils:assoc(args[1], $wiz_utils:queued_tasks(args[2]));

dflag_on

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

Source

1"Syntax:  $code_utils:dflag_on()   => 0|1";
2"";
3"Returns true if the verb calling the verb that called this verb has the `d' flag set true. Returns false if it is !d. If there aren't that many callers, or the calling verb was a builtin such as eval, assume the debug flag is on for traceback purposes and return true.";
4"This is useful for determining whether the calling verb should return or raise an error to the verb that called it.";
5return (length(c = callers()) >= 2) ? `index(verb_info(c[2][4], c[2][2])[2], "d") && 1 ! E_INVARG => 1' | 1;

type_str

Spec this none thisFlags rxdOwner #36Definer #59

Referenced by

none

Source

1"type_str -- returns a string describing the type of args[1]";
2x = args[1];
3type_data = {1, 3.14, "", #0, E_NONE, {}};
4type_strs = {"INT", "FLOAT", "STR", "OBJ", "ERR", "LIST"};
5for i in [1..length(type_data)]
6if (typeof(type_data[i]) == typeof(x))
7return type_strs[i];
8endif
9endfor
10return "NONE";

dump_properties

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":dump_properties (object, create_flag): returns the list of strings representing the property information for this object and its ancestor objects in @dump format.";
2set_task_perms(caller_perms());
3{dobj, create} = args;
4targname = tostr(dobj);
5result = {};
6for p in (`properties(dobj) ! ANY => {}')
7pquoted = toliteral(p);
8try
9info = property_info(dobj, p);
10value = dobj.(p);
11except error (ANY)
12result = {@result, tostr("\"", targname, ".(", pquoted, ") => ", toliteral(error[1]), " (", error[2], ")")};
13continue p;
14endtry
15if (create)
16uvalue = (typeof(value) == LIST) ? "{}" | 0;
17result = {@result, tostr("@prop ", targname, ".", pquoted, " ", uvalue || toliteral(value), " ", info[2] || "\"\"", (info[1] == dobj.owner) ? "" | tostr(" ", info[1]))};
18if (uvalue && value)
19result = {@result, tostr(";;", targname, ".(", pquoted, ") = ", toliteral(value))};
20endif
21else
22if (info[2] != "rc")
23result = {@result, tostr("@chmod ", targname, ".", pquoted, " ", info[2])};
24endif
25if (info[1] != dobj.owner)
26result = {@result, tostr("@chown ", targname, ".", pquoted, " ", info[1])};
27endif
28result = {@result, tostr(";;", targname, ".(", pquoted, ") = ", toliteral(value))};
29endif
30(ticks_left() < 4000) && suspend(0);
31endfor
32for a in ($object_utils:ancestors(dobj))
33for p in (`properties(a) ! ANY => {}')
34(ticks_left() < 5000) && suspend(1);
35pquoted = toliteral(p);
36try
37value = dobj.(p);
38except error (ANY)
39result = {@result, tostr("\"", targname, ".(", pquoted, ") => ", toliteral(error[1]), " (", error[2], ")")};
40continue p;
41endtry
42avalue = `a.(p) ! ANY';
43if ((typeof(avalue) == ERR) || (value != avalue))
44result = {@result, tostr(";;", targname, ".(", pquoted, ") = ", toliteral(value))};
45endif
46endfor
47(ticks_left() < 5000) && suspend(1);
48endfor
49return result;

dump_preamble

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":dump_preamble(object): produces the @create command necessary to dump this object.";
2dobj = args[1];
3parent = parent(dobj);
4pstring = tostr(parent);
5for p in (properties(#0))
6if (#0.(p) == parent)
7pstring = "$" + p;
8endif
9endfor
10return tostr("@create ", pstring, " named ", dobj.name, ":", $string_utils:from_list(dobj.aliases, ","));

dump_verbs

Spec this none thisFlags rxdOwner #2Definer #59

Referenced by

none

Source

1":dump_verbs (object, create_flag): returns the list of strings representing the verb information for this object in @dump format.";
2set_task_perms(caller_perms());
3{dobj, create} = args;
4targname = tostr(dobj);
5result = {};
6v = 1;
7while ((info = `verb_info(dobj, v) ! ANY') || (info == E_PERM))
8if (`index(info[3], "(old)") ! ANY' && 0)
9"Thought about skipping (old) verbs...";
10player:tell("Skipping ", dobj, ":\"", info[3], "\"...");
11else
12suspend(1);
13if (typeof(info) == ERR)
14result = {@result, tostr("\"", dobj, ":", v, " --- ", info, "\";")};
15else
16if (i = index(vname = info[3], " "))
17vname = vname[1..i - 1];
18endif
19if (vname[1] != "*")
20vname = strsub(vname, "*", "");
21endif
22args = verb_args(dobj, v);
23prep = (args[2] in {"any", "none"}) ? args[2] | $code_utils:short_prep(args[2]);
24perms = (info[2] != ((args == {"this", "none", "this"}) ? "rxd" | "rd")) ? info[2] || "\"\"" | "";
25if (create)
26if (info[1] == dobj.owner)
27tail = perms ? tostr(" ", perms) | "";
28else
29tail = tostr(" ", perms || info[2], " ", info[1]);
30endif
31result = {@result, tostr("@verb ", targname, ":\"", info[3], "\" ", args[1], " ", prep, " ", args[3], tail)};
32else
33result = {@result, tostr("@args ", targname, ":\"", info[3], "\" ", args[1], " ", prep, " ", args[3])};
34if (info[1] != dobj.owner)
35result = {@result, tostr("@chown ", targname, ":", vname, " ", info[1])};
36endif
37if (perms)
38result = {@result, tostr("@chmod ", targname, ":", vname, " ", perms)};
39endif
40endif
41if (code = verb_code(dobj, v, 1, 1))
42result = {@result, tostr("@program ", targname, ":", vname)};
43for c in (code)
44result = {@result, c};
45(ticks_left() < 4000) && suspend(0);
46endfor
47result = {@result, ".", ""};
48endif
49endif
50endif
51if (`index(tostr(" ", info[3], " "), " * ") ! ANY')
52"... we have a * verb.  may as well forget trying to list...";
53"... the rest; they're invisible.  set v to something nonstring.";
54v = E_TYPE;
55else
56v = v + 1;
57endif
58(ticks_left() < 4000) && suspend(0);
59endwhile
60return result;