code utilities #51
Aliases: code, utils
64 verbs · 21 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
eval_d | any any any | rx | #51 | 22 |
toint tonum | this none this | rxd | #51 | 4 |
toobj | this none this | rxd | #51 | 2 |
toerr | this none this | rxd | #51 | 10 |
error_name | this none this | rxd | #51 | 3 |
show_object | this none this | rxd | #51 | 60 |
show_property | this none this | rxd | #51 | 17 |
show_verbdef | this none this | rxd | #51 | 22 |
explain_verb_syntax | this none this | rxd | #51 | 19 |
verb_p*erms verb_permi*ssions | this none this | rxd | #51 | 2 |
verb_loc*ation | this none this | rxd | #51 | 2 |
verb_documentation | this none this | rxd | #51 | 19 |
set_verb_documentation | this none this | rxd | #51 | 27 |
parse_propref | this none this | rxd | #51 | 22 |
parse_verbref | this none this | rxd | #51 | 20 |
parse_argspec | this none this | rxd | #51 | 26 |
prepositions | this none this | rxd | #51 | 4 |
short_prep | this none this | rxd | #51 | 14 |
full_prep | this none this | rxd | #51 | 11 |
get_prep | this none this | rxd | #51 | 18 |
_fix_preps | this at/to this | rxd | #51 | 33 |
find_verb_named | this none this | rx | #51 | 14 |
find_last_verb_named | this none this | rxd | #51 | 17 |
find_callable_verb_named | this none this | rxd | #51 | 15 |
verbname_match(new) | this none this | rxd | #51 | 16 |
find_verbs_containing | this none this | rxd | #51 | 32 |
_find_verbs_containing | this none this | rxd | #51 | 22 |
find_verbs_matching | this none this | rxd | #51 | 29 |
_find_verbs_matching | this none this | rxd | #51 | 19 |
_grep_verb_code | this none this | rxd | #51 | 16 |
_egrep_verb_code | this none this | rxd | #51 | 14 |
_parse_audit_args | this none this | rxd | #51 | 29 |
help_db_list | this none this | rxd | #51 | 22 |
help_db_search | this none this | rxd | #51 | 26 |
corify_object | this none this | rxd | #51 | 12 |
inside_quotes | this none this | rxd | #51 | 10 |
verb_or_property | this none this | rxd | #51 | 12 |
task_valid | this none this | rxd | #51 | 3 |
task_owner | this none this | rxd | #51 | 6 |
argstr | this none this | rxd | #51 | 32 |
verbname_match | this none this | rxd | #51 | 18 |
substitute | this none this | rxd | #51 | 21 |
show_who_listing | this none this | rxd | #51 | 133 |
_egrep_verb_code_all | this none this | rxd | #51 | 11 |
_grep_verb_code_all | this none this | rxd | #51 | 11 |
verb_usage | this none this | rxd | #51 | 40 |
verb_frame | this none this | rxd | #51 | 2 |
verb_all_frames | this none this | rxd | #51 | 2 |
move_verb | this none this | rxd | #51 | 39 |
move_prop*erty | this none this | rxd | #51 | 32 |
eval_d_util | this none this | rx | #51 | 1 |
display_callers | this none this | rxd | #51 | 3 |
callers_text | this none this | rxd | #51 | 32 |
set_property_value set_verb_or_property | this none this | rx | #51 | 17 |
owns_task | this none this | rxd | #51 | 3 |
dflag_on | this none this | rxd | #51 | 5 |
type_str | this none this | rxd | #51 | 10 |
dump_properties | this none this | rxd | #51 | 49 |
dump_preamble | this none this | rxd | #51 | 10 |
dump_verbs | this none this | rxd | #51 | 60 |
vargs_to_english | this none this | rxd | #51 | 28 |
tvold | this none this | rxd | #51 | 7 |
copy_verb | this none this | rxd | #51 | 39 |
format_caller | this none this | rxd | #51 | 12 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
_version | #51 | rc | #29 | "1.10.4" |
_multi_preps | #51 | rc | #29 | {"off", "from", "out", "on", "on top", "in", "in front"} |
_other_preps_n | #51 | rc | #29 | list of 13{1, 2, 4, 4, 5, 5, 5, 6, 6, 9, 9, 12, 15} |
_other_preps | #51 | rc | #29 | list of 13{"using", "at", "inside", "into", "on top of", "onto", "upon", "out of", "from inside", "underneath", "beneath", "about", "off of"} |
_short_preps | #51 | rc | #29 | list of 15{"with", "to", "in front of", "in", "on", "from", "over", "through", "under", "behind", "beside", "for", "is", "as", "off"} |
_all_preps | #51 | rc | #29 | 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 | #51 | r | #361 | list of 9{"name", "r", "w", "f", "programmer", "wizard", "owner", "location", "contents"} |
error_names | #51 | rc | #29 | 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 | #51 | rc | #29 | 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 | #51 | rc | #29 | 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 | #72 | rc | #29 | 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\"}, {...}, ...}"} |
aliases | #1 | rc | #29 | {"code", "utils"} |
description | #1 | rc | #29 | {"This is the code utilities utility package. See `help $code_utils' for more details."} |
object_size | #1 | r | #29 | {64029, 1298433815} |
hidden_verbs | #1 | rc | #29 | <clear> |
phelp_msg | #1 | rc | #29 | <clear> |
weight | #1 | rc | #29 | <clear> |
owner_verbs | #1 | rc | #29 | <clear> |
plural_name | #1 | rc | #29 | <clear> |
client_image | #1 | rc | #29 | <clear> |
listening | #1 | rc | #29 | <clear> |
Ancestry
Ancestors (nearest first): #72 Generic Utilities Package → #1 root
Children: none
Call graph
Showing 48 of 78 verbs; 30 not shown.
Source
eval_d
Referenced by
- #2:#* line 40:
$code_utils:eval_d - #31:eval_d line 12:
$code_utils:eval_d - #31:eval_d line 14:
$code_utils:eval_d - #50:eval_cmd_string line 20:
$code_utils:eval_d
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
Referenced by
- #2:@measure line 67:
$code_utils:toint - #2:@ch*eck-full line 9:
$code_utils:toint - #2:@ch*eck-full line 39:
$code_utils:toint - #2:@addalias*# line 40:
$code_utils:toint - #2:@rmalias*# line 26:
$code_utils:toint - #2:@chmod*# line 18:
$code_utils:toint - #6:my_huh line 7:
$code_utils:toint - #6:@rename*# line 15:
$code_utils:toint - #38:_parse_date line 16:
$code_utils:toint - #41:com*pile line 48:
$code_utils:toint - #49:@chown*# line 20:
$code_utils:toint - #49:@quota line 27:
$code_utils:toint - #49:@guests line 2:
$code_utils:toint - #50:@chmod*# line 17:
$code_utils:toint - #50:@args*# line 16:
$code_utils:toint - #50:@rmverb*# line 15:
$code_utils:toint - #50:@prog*ram line 19:
$code_utils:toint - #50:@list*# line 77:
$code_utils:toint - #50:_@prog line 19:
$code_utils:toint - #50:@chown*# line 31:
$code_utils:toint - #59:parse_sticky line 10:
$code_utils:toint - #59:parse_expire line 21:
$code_utils:toint
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
Referenced by
- #2:@set-note-text line 23:
$code_utils:toobj - #20:literal_object line 5:
$code_utils:toobj - #44:object_match_failed line 6:
$code_utils:toobj - #48:object_match_failed line 5:
$code_utils:toobj
Source
1":toobj(objectid as string) => objectid"; 2return match(s = args[1], "^ *#[-+]?[0-9]+ *$") ? toobj(s) | E_TYPE;
toerr
Referenced by
- #20:_toscalar line 16:
$code_utils:toerr
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
Referenced by
- #20:from_value line 30:
$code_utils:error_name - #20:print line 18:
$code_utils:error_name - #20:from_value_suspended line 34:
$code_utils:error_name - #20:_abbreviated_value line 65:
$code_utils:error_name
Source
1"error_name(E_FOO) => \"E_FOO\""; 2return toliteral(@args); 3return this.error_names[toint(args[1]) + 1];
show_object
Referenced by
- #2:@s*how line 17:
$code_utils:show_object - #2:@s*how line 23:
$code_utils:show_object - #50:@s*how line 20:
$code_utils:show_object - #50:@s*how line 26:
$code_utils:show_object
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$command_utils:suspend_if_needed(0); 30player:notify(tostr(" ", v)); 31endfor 32endif 33if ("props" in what) 34if (ps = properties(object)) 35player:notify("Property definitions:"); 36for p in (ps) 37$command_utils:suspend_if_needed(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$command_utils:suspend_if_needed(0); 46strng = `toliteral(object.(p)) + $ansi.reset ! 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$command_utils:suspend_if_needed(0); 58player:notify(tostr(" ", o.name, " (", o, ")")); 59endfor 60endif
show_property
Referenced by
- #2:@s*how line 9:
$code_utils:show_property - #2:@s*how line 20:
$code_utils:show_property - #50:@s*how line 12:
$code_utils:show_property - #50:@s*how line 23:
$code_utils:show_property
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)), $ansi.reset));
show_verbdef
Referenced by
- #2:@s*how line 13:
$code_utils:show_verbdef - #50:@s*how line 16:
$code_utils:show_verbdef
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
Referenced by
- #48:explain_syntax line 9:
$code_utils:explain_verb_syntax
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
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
Referenced by
none
Source
1"returns the object where the current verb is defined."; 2return callers()[1][4];
verb_documentation
Referenced by
- #1:examine_verbs line 33:
$code_utils:verb_documentation - #2:@measure line 8:
$code_utils:verb_documentation - #2:@measure line 118:
$code_utils:verb_documentation - #13:get_topic line 9:
$code_utils:verb_documentation - #13:dump_topic line 8:
$code_utils:verb_documentation - #24:verbdoc line 8:
$code_utils:verb_documentation - #41:comment line 11:
$code_utils:verb_documentation - #41:uncomment line 11:
$code_utils:verb_documentation - #51:set_verb_documentation line 9:
$code_utils:verb_documentation - #68:help_msg line 9:
$code_utils:verb_documentation - #167:biz_help line 12:
$code_utils:verb_documentation
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 (index(line, "\"") == 1) 14doc = {@doc, $no_one:eval("; return " + line)[2]}; 15else 16return doc; 17endif 18endfor 19return doc;
set_verb_documentation
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
Referenced by
- #2:@set*prop line 9:
$code_utils:parse_propref - #2:@set-note-text line 13:
$code_utils:parse_propref - #2:@chmod*# line 51:
$code_utils:parse_propref - #2:@s*how line 7:
$code_utils:parse_propref - #2:@s*how line 19:
$code_utils:parse_propref - #6:@rename*# line 38:
$code_utils:parse_propref - #40:note_match_failed line 1:
$code_utils:parse_propref - #43:y*ank line 25:
$code_utils:parse_propref - #49:@chown*# line 43:
$code_utils:parse_propref - #50:@prop*erty line 12:
$code_utils:parse_propref - #50:@chmod*# line 50:
$code_utils:parse_propref - #50:@rmprop*erty line 2:
$code_utils:parse_propref - #50:@s*how line 10:
$code_utils:parse_propref - #50:@s*how line 22:
$code_utils:parse_propref - #50:@check-p*roperty line 4:
$code_utils:parse_propref - #50:@clearp*roperty line 4:
$code_utils:parse_propref - #50:@writeprop line 4:
$code_utils:parse_propref - #50:@canedit line 59:
$code_utils:parse_propref - #50:@chown*# line 69:
$code_utils:parse_propref - #113:@nnlist line 1:
$code_utils:parse_propref - #317:@addex line 1:
$code_utils:parse_propref
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
Referenced by
- #2:@addalias*# line 31:
$code_utils:parse_verbref - #2:@rmalias*# line 17:
$code_utils:parse_verbref - #2:@edit line 5:
$code_utils:parse_verbref - #2:@chmod*# line 9:
$code_utils:parse_verbref - #2:@s*how line 11:
$code_utils:parse_verbref - #6:@rename*# line 9:
$code_utils:parse_verbref - #13:find_topics line 1:
$code_utils:parse_verbref - #13:get_topic line 3:
$code_utils:parse_verbref - #13:dump_topic line 2:
$code_utils:parse_verbref - #41:com*pile line 15:
$code_utils:parse_verbref - #41:parse_invoke line 6:
$code_utils:parse_verbref - #43:y*ank line 54:
$code_utils:parse_verbref - #49:@chown*# line 15:
$code_utils:parse_verbref - #50:@chmod*# line 8:
$code_utils:parse_verbref - #50:@args*# line 10:
$code_utils:parse_verbref - #50:@verb line 10:
$code_utils:parse_verbref - #50:@rmverb*# line 2:
$code_utils:parse_verbref - #50:@copy line 13:
$code_utils:parse_verbref - #50:@copy line 22:
$code_utils:parse_verbref - #50:@prog*ram line 12:
$code_utils:parse_verbref - #50:@s*how line 14:
$code_utils:parse_verbref - #50:@list*# line 10:
$code_utils:parse_verbref - #50:_@prog line 12:
$code_utils:parse_verbref - #50:find_help line 19:
$code_utils:parse_verbref - #50:@changelog line 15:
$code_utils:parse_verbref - #50:@disassemble line 2:
$code_utils:parse_verbref - #50:@chown*# line 26:
$code_utils:parse_verbref
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}; 17elseif ((s && (s[1] == "$")) && has_callable_verb(#0, s[2..$])) 18return {"#0", s[2..$]}; 19endif 20return 0;
parse_argspec
Referenced by
- #41:com*pile line 15:
$code_utils:parse_argspec - #41:parse_invoke line 11:
$code_utils:parse_argspec - #50:@args*# line 25:
$code_utils:parse_argspec - #50:@verb line 31:
$code_utils:parse_argspec - #50:@rmverb*# line 6:
$code_utils:parse_argspec - #50:@prog*ram line 16:
$code_utils:parse_argspec - #50:@list*# line 49:
$code_utils:parse_argspec - #50:_@prog line 16:
$code_utils:parse_argspec - #70:parse_verb_args line 7:
$code_utils:parse_argspec
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
Referenced by
- #15:prepositions line 2:
$code_utils:prepositions
Source
1if (server_version() != this._version) 2this:_fix_preps(); 3endif 4return this.prepositions;
short_prep
Referenced by
- #2:@d*isplay line 165:
$code_utils:short_prep - #20:parse_command line 40:
$code_utils:short_prep - #41:local_editing_info line 6:
$code_utils:short_prep - #50:@d*isplay line 165:
$code_utils:short_prep - #51:explain_verb_syntax line 5:
this:short_prep - #51:dump_verbs line 23:
$code_utils:short_prep - #70:check_verb_args line 8:
$code_utils:short_prep
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
Referenced by
- #6:my_huh line 11:
$code_utils:full_prep - #6:last_huh line 18:
$code_utils:full_prep - #20:parse_command line 38:
$code_utils:full_prep - #41:com*pile line 29:
$code_utils:full_prep - #41:parse_invoke line 17:
$code_utils:full_prep - #50:@rmverb*# line 27:
$code_utils:full_prep - #50:@prog*ram line 47:
$code_utils:full_prep - #50:@list*# line 55:
$code_utils:full_prep - #50:_@prog line 47:
$code_utils:full_prep
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
Referenced by
- #20:parse_command line 17:
$code_utils:get_prep - #51:parse_argspec line 17:
$code_utils:get_prep
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
Referenced by
- #51:prepositions line 2:
this:_fix_preps - #51:short_prep line 4:
this:_fix_preps - #51:full_prep line 2:
this:_fix_preps
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
Referenced by
- #41:com*pile line 34:
$code_utils:find_verb_named - #41:com*pile line 36:
$code_utils:find_verb_named - #41:parse_invoke line 24:
$code_utils:find_verb_named - #41:parse_invoke line 27:
$code_utils:find_verb_named - #48:explain_syntax line 8:
$code_utils:find_verb_named - #50:@prog*ram line 49:
$code_utils:find_verb_named - #50:@prog*ram line 51:
$code_utils:find_verb_named - #50:@list*# line 85:
$code_utils:find_verb_named - #50:@list*# line 87:
$code_utils:find_verb_named - #50:_@prog line 49:
$code_utils:find_verb_named - #50:_@prog line 51:
$code_utils:find_verb_named - #113:@vloc line 26:
$code_utils:find_verb_named
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
Referenced by
- #50:@rmverb*# line 25:
$code_utils:find_last_verb_named - #50:@rmverb*# line 29:
$code_utils:find_last_verb_named
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
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)
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
Referenced by
- #49:@who-calls line 7:
$code_utils:find_verbs_containing
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()) 17if ((toint(o) % 4) == 0) 18player:notify(tostr("...", o)); 19endif 20suspend(1); 21endif 22endfor 23elseif (typeof(where) == LIST) 24for o in (where) 25count = count + this:_find_verbs_containing(pattern, o); 26endfor 27else 28"...typeof(where) == OBJ..."; 29count = this:_find_verbs_containing(pattern, where); 30endif 31player:notify(""); 32player:notify(tostr("Total: ", count, " verbs."));
_find_verbs_containing
Referenced by
- #51:find_verbs_containing line 14:
this:_find_verbs_containing - #51:find_verbs_containing line 25:
this:_find_verbs_containing - #51:find_verbs_containing line 29:
this:_find_verbs_containing
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, ") => ", verbs)); 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(1); 20endif 21endfor 22return count;
find_verbs_matching
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(1); 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
Referenced by
- #51:find_verbs_matching line 14:
this:_find_verbs_matching - #51:find_verbs_matching line 23:
this:_find_verbs_matching - #51:find_verbs_matching line 26:
this:_find_verbs_matching
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 17$cu:sin(1, "...", o); 18endfor 19return count;
_grep_verb_code
Referenced by
- #51:_find_verbs_containing line 12:
this:_grep_verb_code
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]; 5"The following gross kluge is due to Quade (#82589). tostr is fast, and so we can check for nonexistence of a pattern very quickly this way rather than checking line by line. MOO needs a compiler. --Nosredna"; 6vc = `verb_code(@listdelete(args, 1)) ! ANY'; 7if ((typeof(vc) == ERR) || (!index(tostr(@vc), pattern))) 8return 0; 9else 10for line in (vc) 11if (index(line, pattern)) 12return line; 13endif 14endfor 15return 0; 16endif
_egrep_verb_code
Referenced by
- #41:@queue-grep line 12:
$code_utils:_egrep_verb_code - #51:_find_verbs_matching line 12:
this:_egrep_verb_code
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
Referenced by
- #2:@audit line 13:
$code_utils:_parse_audit_args - #50:@pros*pectus line 11:
$code_utils:_parse_audit_args
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
Referenced by
- #2:?* line 12:
$code_utils:help_db_list - #50:@gethelp line 8:
$code_utils:help_db_list - #50:find_help line 3:
$code_utils:help_db_list - #52:full_index line 2:
$code_utils:help_db_list - #52:index_list line 3:
$code_utils:help_db_list - #90:get_help_topic line 9:
$code_utils:help_db_list
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);
help_db_search
Referenced by
- #2:?* line 13:
$code_utils:help_db_search - #24:forward line 8:
$code_utils:help_db_search - #50:@gethelp line 27:
$code_utils:help_db_search - #50:find_help line 6:
$code_utils:help_db_search - #90:get_help_topic line 11:
$code_utils:help_db_search
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$command_utils:suspend_if_needed(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
Referenced by
- #13:dump_topic line 11:
$code_utils:corify_object - #24:dump_topic line 3:
$code_utils:corify_object - #50:@gethelp line 34:
$code_utils:corify_object - #50:@canedit line 19:
$code_utils:corify_object - #52:dump_topic line 4:
$code_utils:corify_object - #253:_changelog_object line 3:
$code_utils:corify_object - #253:_changelog_object line 5:
$code_utils:corify_object
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
Referenced by
- #31:bad_eval line 10:
$code_utils:inside_quotes - #51:substitute line 12:
this:inside_quotes
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
Referenced by
- #6:add_feature line 11:
$code_utils:verb_or_property - #24:objectdoc line 7:
$code_utils:verb_or_property - #45:less_than_eq line 10:
$code_utils:verb_or_property - #65:replace line 22:
$code_utils:verb_or_property - #84:@paste line 17:
$code_utils:verb_or_property - #84:@paste line 22:
$code_utils:verb_or_property - #107:is_wearing line 8:
$code_utils:verb_or_property - #118:feature_add line 2:
$code_utils:verb_or_property - #118:command_on line 8:
$code_utils:verb_or_property - #118:command_history line 5:
$code_utils:verb_or_property - #118:command_who line 5:
$code_utils:verb_or_property - #138:rot_check line 23:
$code_utils:verb_or_property - #327:_invoke line 5:
$code_utils:verb_or_property
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; 8if (has_callable_verb(object, name)) 9return object:(name)(@rest); 10else 11return `object.(name) ! ANY'; 12endif
task_valid
Referenced by
- #11:report_prune_progress line 16:
$code_utils:task_valid - #17:boot_idlers line 14:
$code_utils:task_valid - #39:sending line 3:
$code_utils:task_valid - #49:@abort-sh*utdown line 3:
$code_utils:task_valid - #49:@shutdown line 4:
$code_utils:task_valid - #65:continuous line 6:
$code_utils:task_valid - #65:move_players_home line 6:
$code_utils:task_valid - #66:add_queued_mail line 5:
$code_utils:task_valid - #69:get line 11:
$code_utils:task_valid
Source
1"task_valid(INT id)"; 2"Return true iff there is currently a valid task with the given id."; 3return (typeof(args[1]) == INT) ? task_valid(args[1]) | 0;
task_owner
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
Referenced by
- #43:huh2 line 12:
$code_utils:argstr - #43:here_huh line 11:
$code_utils:argstr
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
Referenced by
- #51:find_verb_named line 10:
this:verbname_match - #51:find_last_verb_named line 13:
this:verbname_match - #51:find_callable_verb_named line 11:
this:verbname_match
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..$]; 15$cu:sin(0); 16endwhile 17endif 18return 0;
substitute
Referenced by
- #2:#* line 54:
$code_utils:substitute - #2:#* line 56:
$code_utils:substitute - #41:com*pile line 56:
$code_utils:substitute - #50:eval_cmd_string line 16:
$code_utils:substitute
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
Referenced by
- #2:@w*h*o line 8:
$code_utils:show_who_listing - #4:w*ho line 10:
$code_utils:show_who_listing - #4:w*ho line 18:
$code_utils:show_who_listing - #4:who(vanilla) line 4:
$code_utils:show_who_listing - #4:who(vanilla) line 7:
$code_utils:show_who_listing
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$command_utils:suspend_if_needed(0); 54p = lst[3]; 55namestr = tostr($ansi:strip(p:real_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) ? $su:nn(p.location) | 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
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
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
Referenced by
- #25:@request line 11:
$code_utils:verb_usage
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
Referenced by
none
Source
1"returns the callers() frame for the current verb."; 2return callers()[1];
verb_all_frames
Referenced by
none
Source
1"returns {this:verb_frame(), @callers()}."; 2return callers();
move_verb
Referenced by
- #50:@copy line 40:
$code_utils:move_verb
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
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
Referenced by
- #51:eval_d line 21:
this:eval_d_util
Source
1"Do not remove this verb! This is an auxiliary verb for :eval_d().";
display_callers
Referenced by
- #2:@ch*eck-full line 55:
$code_utils:display_callers
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
Referenced by
- #51:display_callers line 3:
this:callers_text
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$command_utils:suspend_if_needed(3); 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, "(", gamevalid(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
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
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
Referenced by
- #0:bf_chparent line 36:
$code_utils:dflag_on - #0:bf_add_verb line 26:
$code_utils:dflag_on - #0:bf_add_property line 24:
$code_utils:dflag_on - #0:bf_set_verb_info line 23:
$code_utils:dflag_on - #0:bf_match line 2:
$code_utils:dflag_on - #0:bf_rmatch line 2:
$code_utils:dflag_on - #0:bf_force_input line 13:
$code_utils:dflag_on - #0:bf_set_property_info line 22:
$code_utils:dflag_on - #42:_chparent line 23:
$code_utils:dflag_on
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
Referenced by
- #20:spr*intf line 69:
$code_utils:type_str
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
Referenced by
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$command_utils:suspend_if_needed(0); 31endfor 32for a in ($object_utils:ancestors(dobj)) 33for p in (`properties(a) ! ANY => {}') 34$command_utils:suspend_if_needed(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$command_utils:suspend_if_needed(1); 48endfor 49return result;
dump_preamble
Referenced by
- #50:@dump line 39:
$code_utils:dump_preamble
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
Referenced by
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$command_utils:suspend_if_needed(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$command_utils:suspend_if_needed(0); 59endwhile 60return result;
vargs_to_english
Referenced by
- #1:examine_verbs line 31:
$code_utils:vargs_to_english
Source
1arglist = args[1]; 2what = args[2]; 3st = ""; 4if (arglist == {"any", "any", "any"}) 5return " <anything>"; 6endif 7name = is_a(what, $room) ? "here" | ((pname = `what:name() ! ANY => ""') ? pname | what.name); 8for x in (arglist) 9if (x == "this") 10st = (st + " ") + name; 11elseif (x == "any") 12st = st + " <something>"; 13elseif (x == "none") 14"ignore..."; 15else 16if (x == "with/using") 17x = "with"; 18elseif (x == "at/to") 19x = "to"; 20elseif (x == "out of/from inside/from") 21x = "from"; 22elseif (x == "on top of/on/onto/upon") 23x = "on"; 24endif 25st = (st + " ") + x; 26endif 27endfor 28return st;
tvold
Referenced by
none
Source
1"Copied from code utilities (#59):task_valid by Satan (#2) Wed Mar 31 23:11:03 2004 PST"; 2"task_valid(INT id)"; 3"Return true iff there is currently a valid task with the given id."; 4set_task_perms($no_one); 5{id} = args; 6t = $list_utils:slice(queued_tasks(), 1); 7return ((id == task_id()) || (id in t)) || (E_PERM == `kill_task(id) ! ANY');
copy_verb
Referenced by
- #334:instantiate line 10:
$code_utils:copy_verb - #334:instantiate_new line 9:
$code_utils:copy_verb - #334:instantiate_old line 13:
$code_utils:copy_verb
Source
1"Copied from code utilities (#59):move_verb by Satan (#2) Mon Jun 27 23:58:20 2005 CDT"; 2":copy_verb(OBJ from, STR verb name, OBJ to, [STR new verb name]) -> Copies 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."; 3"Should handle verbnames with aliases and wildcards correctly."; 4who = caller_perms(); 5{from, origverb, to, ?destverb = origverb} = args; 6if ((((typeof(from) != OBJ) || (typeof(to) != OBJ)) || (typeof(origverb) != STR)) || (typeof(destverb) != STR)) 7"check this first so we can parse out long verb names next"; 8return E_TYPE; 9endif 10origverb_first = strsub(origverb[1..index(origverb + " ", " ") - 1], "*", "") || "*"; 11destverb_first = strsub(destverb[1..index(destverb + " ", " ") - 1], "*", "") || "*"; 12if ((!valid(from)) || (!valid(to))) 13return E_INVARG; 14elseif ((from == to) && (destverb == origverb)) 15"Moving same origverb onto the same object puts the verbcode in the wrong one. Just not allow"; 16return E_NACC; 17elseif (((!$perm_utils:controls(who, from)) && (!from.w)) || ((!$perm_utils:controls(who, to)) && (!to.w))) 18"caller_perms() is not allowed to hack on either object in question"; 19return E_PERM; 20elseif (!$object_utils:defines_verb(from, origverb_first)) 21"verb is not defined on the from object"; 22return E_VERBNF; 23elseif ((vinfo = verb_info(from, origverb_first)) && (!$perm_utils:controls(who, vinfo[1]))) 24"caller_perms() is not permitted to add a verb with the existing verb owner"; 25return E_PERM; 26elseif (!who.programmer) 27return E_PERM; 28else 29"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)"; 30vcode = verb_code(from, origverb_first); 31vargs = verb_args(from, origverb_first); 32vinfo[3] = (destverb == origverb) ? vinfo[3] | destverb; 33if (typeof(res = `add_verb(to, vinfo, vargs) ! ANY') == ERR) 34return res; 35else 36set_verb_code(to, destverb_first, vcode); 37return {to, vinfo[3]}; 38endif 39endif
format_caller
Referenced by
- #57:watch_tell line 39:
$code_utils:format_caller
Source
1{c, ?show_this = 0} = args; 2s = tostr(c[4], ":", c[2]); 3if (length(c) > 5) 4s = tostr(s, "(", c[6], ")"); 5endif 6if (!show_this) 7return s; 8endif 9if (c[1] != c[4]) 10s = ((s + " (this == ") + $su:nn(c[1])) + ")"; 11endif 12return s;