object utilities #45

Parent #72Owner #361Flags readSource hellcore/hellcore.db

Aliases: object utilities

57 verbs · 12 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
has_property has_propthis none thisrxd#451
all_properties all_verbsthis none thisrxd#4514
has_verbthis none thisrxd#454
has_callable_verbthis none thisrxd#454
match_verbthis none thisrxd#4512
isathis none thisrxd#452
ancestorsthis none thisrxd#4511
ordered_descendantsthis none thisrxd#459
containsthis none thisrxd#4512
all_contentsthis none thisrxd#456
findable_propertiesthis none thisrxd#4512
owned_propertiesthis none thisrxd#4515
property_conflictsthis none thisrxd#4531
descendants_with_property_suspendedthis none thisrxd#4513
locationsthis none thisrxd#458
all_properties_suspended all_verbs_suspendedthis none thisrxd#4515
connectedthis none thisrxd#454
isoneofthis none thisrxd#459
defines_verbthis none thisrxd#456
defines_propertythis none thisrxd#458
has_any_verb has_any_propertythis none thisrxd#453
has_readable_prop*erty hrpthis none thisrxd#458
descendants descendentsthis none thisrxd#4510
leavesthis none thisrxd#4511
branchesthis none thisrxd#4512
descendants_suspended descendents_suspendedthis none thisrxd#4513
leaves_suspendedthis none thisrxd#4513
branches_suspendedthis none thisrxd#4516
disown disinheritthis none thisrxd#4521
accessible_verbsthis none thisrxd#4510
fertile_kidsthis none thisrxd#458
has_athis none thisrxd#458
fertile_branchesthis none thisrxd#4516
verb_namethis none thisrxd#456
fertile_kids_suspendedthis none thisrxd#459
fertile_descendants_suspendedthis none thisrxd#4510
objects_with_verbthis none thisrxd#4523
tree_propertiesthis none thisrxd#4527
siblingsthis none thisrxd#452
limited_childrenthis none thisrxd#457
limited_children_suspendedthis none thisrxd#458
has_verb_and_argsthis none thisrxd#458
property_definerthis none thisrxd#4511
is_in_athis none thisrxd#451
treesizethis none thisrxd#4510
is_truethis none thisrxd#4512
bf_opthis none thisrxd#4511
bf_op_eq_to bf_op_equal_to bf_op_eq bf_op_greater_than bf_op_gt bf_op_less_than bf_op_lt bf_op_not_equal_to bf_op_ne bf_op_greater_than_eq bf_op_ge bf_op_less_than_eq bf_op_lethis none thisrxd#4524
less_than_eq greater_than_eq greater_than less_than equal_to eq le gt ge lt not_equal_to nethis none thisrxd#4524
verb_definerthis none thisrxd#4515
children_hash chthis none thisrxd#458
property_hashthis none thisrxd#457
reverse_property_hash rphthis none thisrxd#4511
propgrepthis none thisrxd#4518
map_leaves_suspendedthis none thisrxd#4520
map_leavesthis none thisrxd#4519
fastfindthis none thisrxd#4520

Properties

PropertyDefinerFlagsOwnerValue
ordinal_regexp_old#45rc#361""
help_msg#72rc#361
list of 75{"*** NOTE: for more help on any verb, do 'help $ou:verbname'.", "", "These routines are useful for finding out information about objects and the object tree. They can be very slow with large trees; verbs with an asterisk have a suspending version of the verb named '(verbname)_suspended' to help.", "", " Inheritance & hierarchy:", "", ":descendants * (obj) => kids, kids of kids, ...", ":limited_children * (obj, n) => descendants down to level n", ":ordered_descendants (obj) => depth-first (the above is breadth)", ":leaves * (obj) => descendants with no children", ":branches * (obj) => descendants with children ", ":fertile_kids * (obj) => kids that are +f", ":fertile_branches (obj) => like branches, but +f only", "", ":descendants_with_property_suspended (obj, pname)", " => like descendants, but only objs with .pname defined.", ":objects_with_verb (vname, obj)", " => like descendants, but only objs with :vname defined.", "", ":ancestors (obj [,obj ,...]) ", " => parents, parents of parents, ...", ":property_conflicts (obj, newparent)", " => list of {prop, objs-with-prop} that would conflict", ":tree_properties (obj, propname) ", " => for every descendant of obj, {obj, propvalue}", ":has_a (obj-list, parent-obj) ", " => return first obj in list which is a parent-obj", "", " Boolean inheritance checking:", ":isa (obj, parent-obj) => true if obj is a parent-obj.", " - the above is deprecated: use the builtin is_a(obj, parent_obj).", ":isoneof (obj, parent-list) => true if object :isa class in list of parents", "", " What's in what (contents):", ":contains (obj1, obj2) => Does obj1 contain obj2 (nested)?", ":all_contents (object) => contents, contents of contents, ...", ":locations (object) => location, location.location, ...", "", " Verb & property info:", "", ":all_verbs (obj) => verbs on obj and all parents", ":all_properties * (obj) => props on obj and all parents", ":findable_properties(obj) => props that are readable by caller", ":owned_properties (obj [,owner]) => props owned by owner/caller", "", ":has_property (obj,pname) => does obj.pname exist?", ":has_readable_property(obj,pname)=> does obj.pname exist & is it +r?", ":defines_property (obj,pname) => is .pname defined on obj?", ":has_verb (obj,vname) => does obj:vname exist?", ":has_callable_verb (obj,vname) => does obj:vname exist & is it +x?", ":defines_verb (obj,vname) => is :vname defined on obj?", ":match_verb (obj,vname) ", " => finds the object :vname is defined on. {obj, vname} or {}.", ":accessible_verbs (obj) ", " => a list of verbs that you can access (or E_PERM)", ":has_verb_and_args (obj, vname, iobjarg, preparg, dobjarg)", " => does the given verb exist, with given args?", "", ":verb_name(\"verb*names like this\") => \"verb\"", "", "$lu:remove_* Utilities:", " The following are designed for use with the wonderful $lu:remove_* and return true or false values only.", "", ":bf_op (obj, ref, func, @args)", " => completes prop refs for obj and then returns truth of $bf:(func)(ref, @args)", ":is_true (obj, ref)", " => completes prop references for obj and then returns truth value", ":gt/lt/ge/le/eq/ne (obj, ref, val)", " => completes prop references for obj and then compares the result with val", ":bf_op_(gt/lt/etc) (obj, ref, func, val, @args)", " => same as the above except compares the result of $bf(func)(ref, @args) with val", "", " Misc info:", "", ":connected (obj) => is this a connected player?"}
aliases#1rc#361{"object utilities"}
description#1rc#361{"This is the object utilities utility package. See `help $object_utils' for more details."}
object_size#1r#29{38145, 1298433815}
hidden_verbs#1rc#361<clear>
phelp_msg#1rc#361<clear>
weight#1rc#361<clear>
owner_verbs#1rc#361<clear>
plural_name#1rc#361<clear>
client_image#1rc#361<clear>
listening#1rc#361<clear>

Ancestry

Ancestors (nearest first): #72 Generic Utilities Package#1 root

Children: none

Call graph

calls n45_9 #45:all_contents n45_9->n45_9 n45_12 #45:property_conflicts n42_0 #42:controls n45_12->n42_0 n45_25 #45:descendants_suspended n45_12->n45_25 n48_8 #48:suspend_if_needed n45_12->n48_8 n45_25->n48_8 n45_13 #45:descendants_with_property_suspended n45_13->n45_13 n45_15 #45:all_properties_suspended n45_15->n48_8 n45_19 #45:defines_property n45_0 #45:has_property n45_19->n45_0 n45_27 #45:branches_suspended n45_27->n48_8 n45_28 #45:disown n45_28->n42_0 n45_31 #45:has_a n45_5 #45:isa n45_31->n45_5 n45_32 #45:fertile_branches n45_32->n48_8 n45_32->n45_32 n45_33 #45:verb_name n20_38 #20:explode n45_33->n20_38 n45_34 #45:fertile_kids_suspended n45_34->n48_8 n45_35 #45:fertile_descendants_suspended n45_35->n48_8 n45_36 #45:objects_with_verb n45_36->n45_25 n45_36->n48_8 n45_37 #45:tree_properties n45_37->n48_8 n45_39 #45:limited_children n47_10 #47:append n45_39->n47_10 n45_40 #45:limited_children_suspended n45_40->n48_8 n45_40->n47_10 n45_42 #45:property_definer n47_11 #47:reverse n45_42->n47_11 n45_6 #45:ancestors n45_42->n45_6 n45_48 #45:less_than_eq n51_36 #51:verb_or_property n45_48->n51_36

Source

has_property has_prop

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1return valid(args[1]) && has_property(@args);

all_properties all_verbs

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1"Syntax:  all_properties (OBJ what)";
2"         all_verbs      (OBJ what)";
3"";
4"Returns all properties or verbs defined on `what' and all of its ancestors. Uses wizperms to get properties or verbs if the caller of this verb owns what, otherwise, uses caller's perms.";
5what = args[1];
6if (what.owner != caller_perms())
7set_task_perms(caller_perms());
8endif
9bif = (verb == "all_verbs") ? "verbs" | "properties";
10res = `call_function(bif, what) ! E_PERM => {}';
11while (valid(what = parent(what)))
12res = {@`call_function(bif, what) ! E_PERM => {}', @res};
13endwhile
14return res;

has_verb

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":has_verb(OBJ object, STR verbname)";
2"Find out if an object has a verb matching the given verbname.";
3"Returns {location} if so, 0 if not, where location is the object or the ancestor on which the verb is actually defined.";
4return valid(args[1]) && has_callable_verb(@args);

has_callable_verb

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1"Usage:  has_callable_verb(object, verb)";
2"See if an object has a verb that can be called by another verb (i.e., that has its x permission bit set).";
3"Return {location}, where location is the object that defines the verb, or 0 if the object doesn't have the verb.";
4return valid(args[1]) && has_callable_verb(@args);

match_verb

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":match_verb(OBJ object, STR verb)";
2"Find out if an object has a given verb, and some information about it.";
3"Returns {OBJ location, STR verb} if matched, 0 if not.";
4"Location is the object on which it is actually defined, verb is a name";
5"for the verb which can subsequently be used in verb_info (i.e., no";
6"asterisks).";
7verbname = strsub(args[2], "*", "");
8object = args[1];
9while (E_VERBNF == (info = `verb_info(object, verbname) ! E_VERBNF, E_INVARG'))
10object = parent(object);
11endwhile
12return info ? {object, verbname} | 0;

isa

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1":isa(x,y) == valid(x) && (y==x || y in :ancestors(x))";
2return is_a(@args);

ancestors

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1"Usage:  ancestors(object[, object...])";
2"Return a list of all ancestors of the object(s) in args, with no duplicates.";
3"If called with a single object, the result will be in order ascending up the inheritance hierarchy.  If called with multiple objects, it probably won't.";
4ret = {};
5for o in (args)
6what = o;
7while (valid(what = parent(what)))
8ret = setadd(ret, what);
9endwhile
10endfor
11return ret;

ordered_descendants

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

none

Source

1r = {what = args[1]};
2for k in (children(what))
3if (children(k))
4r = {@r, @this:(verb)(k)};
5else
6r = {@r, k};
7endif
8endfor
9return r;

contains

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1"$object_utils:contains(obj1, obj2) -- does obj1 contain obj2?";
2"";
3"Return true iff obj2 is under obj1 in the containment hierarchy; that is, if obj1 is obj2's location, or its location's location, or ...";
4{loc, what} = args;
5return is_in(what, loc);
6while (valid(what))
7what = what.location;
8if (what == loc)
9return valid(loc);
10endif
11endwhile
12return 0;

all_contents

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1"all_contents(object)";
2"Return a list of all objects contained (at some level) by object.";
3for y in (res = args[1].contents)
4y.contents && (res = {@res, @this:all_contents(y)});
5endfor
6return res;

findable_properties

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1"findable_properties(object)";
2"Return a list of properties on those members of object's ancestor list that are readable or are owned by the caller (or all properties if the caller is a wizard).";
3what = args[1];
4props = {};
5who = caller_perms();
6while (what != $nothing)
7if ((what.r || (who == what.owner)) || who.wizard)
8props = {@properties(what), @props};
9endif
10what = parent(what);
11endwhile
12return props;

owned_properties

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1"owned_properties(what[, who])";
2"Return a list of all properties on WHAT owned by WHO.";
3"Only wizardly verbs can specify WHO; mortal verbs can only search for properties owned by their own owners.  For more information, talk to Gary_Severn.";
4what = anc = args[1];
5who = ((c = caller_perms()).wizard && (length(args) > 1)) ? args[2] | c;
6props = {};
7while (anc != $nothing)
8for k in (properties(anc))
9if (property_info(what, k)[1] == who)
10props = listappend(props, k);
11endif
12endfor
13anc = parent(anc);
14endwhile
15return props;

property_conflicts

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":property_conflicts(object,newparent)";
2"Looks for propertyname conflicts that would keep chparent(object,newparent)";
3"  from working.";
4"Returns a list of elements of the form {<propname>, @<objectlist>}";
5"where <objectlist> is list of descendents of object defining <propname>.";
6if (!valid(object = args[1]))
7return E_INVARG;
8elseif (!valid(newparent = args[2]))
9return (newparent == #-1) ? {} | E_INVARG;
10elseif (!($perm_utils:controls(caller_perms(), object) && (newparent.f || $perm_utils:controls(caller_perms(), newparent))))
11"... if you couldn't chparent anyway, you don't need to know...";
12return E_PERM;
13endif
14"... properties existing on newparent";
15"... cannot be present on object or any descendent...";
16props = conflicts = {};
17for o in ({object, @$object_utils:descendents_suspended(object)})
18for p in (properties(o))
19if (`property_info(newparent, p) ! E_PROPNF => 0')
20if (i = p in props)
21conflicts[i] = {@conflicts[i], o};
22else
23props = {@props, p};
24conflicts = {@conflicts, {p, o}};
25endif
26endif
27$command_utils:suspend_if_needed(0);
28endfor
29$command_utils:suspend_if_needed(0);
30endfor
31return conflicts;

descendants_with_property_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":descendants_with_property_suspended(object,property)";
2" => list of descendants of object on which property is defined.";
3"calls suspend(0) as needed";
4{object, prop} = args;
5yield;
6if (`property_info(object, prop) ! E_PROPNF => 0')
7return {object};
8endif
9r = {};
10for c in (children(object))
11r = {@r, @this:descendants_with_property_suspended(c, prop)};
12endfor
13return r;

locations

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1"Usage:  locations(object)";
2"Return a listing of the location hierarchy above object.";
3ret = {};
4what = args[1];
5while (valid(what = what.location))
6ret = {@ret, what};
7endwhile
8return ret;

all_properties_suspended all_verbs_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1"Syntax:  all_properties_suspended (OBJ what)";
2"         all_verbs_suspended      (OBJ what)";
3"";
4"Returns all properties or verbs defined on `what' and all of its ancestors. Uses wizperms to get properties or verbs if the caller of this verb owns what, otherwise, uses caller's perms. Suspends as necessary";
5what = args[1];
6if (what.owner != caller_perms())
7set_task_perms(caller_perms());
8endif
9bif = (verb == "all_verbs") ? "verbs" | "properties";
10res = `call_function(bif, what) ! E_PERM => {}';
11while (valid(what = parent(what)))
12res = {@`call_function(bif, what) ! E_PERM => {}', @res};
13$command_utils:suspend_if_needed(0);
14endwhile
15return res;

connected

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1":connected(object) => true if object is a connected player.";
2"equivalent to (object in connected_players()) for valid players, perhaps with less server overhead.";
3"use object:is_listening() if you want to allow for puppets and other non-player objects that still 'care' about what's said.";
4return typeof(`connected_seconds(@args) ! E_INVARG') == INT;

isoneof

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

none

Source

1":isoneof(x,y) = x isa z, for some z in list y";
2{what, targ} = args;
3while (valid(what))
4if (what in targ)
5return 1;
6endif
7what = parent(what);
8endwhile
9return 0;

defines_verb

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1"Returns 1 if the verb is actually *defined* on this object, 0 else.";
2"Use this instead of :has_verb if your aim is to manipulate that verb code or whatever.";
3return `verb_info(@args) ! ANY => 0' && 1;
4"Old code below...Ho_Yan 10/22/96";
5info = verb_info(@args);
6return typeof(info) != ERR;

defines_property

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":defines_property(OBJ object, STR property name) => Returns 1 if the property is actually *defined* on the object given";
2if (!valid(o = args[1]))
3return 0;
4elseif (!valid(p = parent(o)))
5return this:has_property(o, args[2]);
6else
7return (!this:has_property(p, args[2])) && this:has_property(o, args[2]);
8endif

has_any_verb has_any_property

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":has_any_verb(object) / :has_any_property(object)";
2" -- does `object' have any verbs/properties?";
3return !(!`(verb == "has_any_verb") ? verbs(args[1]) | properties(args[1]) ! E_INVARG => 0');

has_readable_prop*erty hrp

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":has_readable_property(OBJ object, STR property name) => 1 if property exists and is publically readable (has the r flag set true).";
2{object, prop} = args;
3try
4pinfo = property_info(object, prop);
5return index(pinfo[2], "r") != 0;
6except (E_PROPNF)
7return (prop in $code_utils.builtin_props) > 0;
8endtry

descendants descendents

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1":descendants (OBJ object) => {OBJs} all nested children of <object>";
2r = children(args[1]);
3i = 1;
4while (i <= length(r))
5if (kids = children(r[i]))
6r = {@r, @kids};
7endif
8i = i + 1;
9endwhile
10return r;

leaves

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1twigs = {args[1]};
2leaves = {};
3while (twigs)
4{l, @twigs} = twigs;
5if (kids = children(l))
6twigs = {@kids, @twigs};
7else
8leaves = {@leaves, l};
9endif
10endwhile
11return leaves;

branches

Spec this none thisFlags rxdOwner #29Definer #45

Referenced by

Source

1":branches (OBJ object) => {OBJs} descendants of <object> that have children";
2r = args[1..1];
3i = 1;
4while (i <= length(r))
5if (kids = children(r[i]))
6r[i + 1..i] = kids;
7i = i + 1;
8else
9r[i..i] = {};
10endif
11endwhile
12return r;

descendants_suspended descendents_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":descendants_suspended (OBJ object) => {OBJs} all nested children of <object>";
2set_task_perms(caller_perms());
3{what, ?susptime = 1} = args;
4r = children(what);
5i = 1;
6while (i <= length(r))
7if (kids = children(r[i]))
8r = {@r, @kids};
9endif
10i = i + 1;
11$cu:sin(susptime);
12endwhile
13return r;

leaves_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1{what, ?ytime = 1} = args;
2twigs = {what};
3leaves = {};
4while (twigs)
5{l, @twigs} = twigs;
6if (kids = children(l))
7twigs = {@kids, @twigs};
8else
9leaves = {@leaves, l};
10endif
11yield ytime;
12endwhile
13return leaves;

branches_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":branches_suspended (OBJ object [, INT suspend]) => {OBJs} all descendants of";
2"                                                    <object> with children.";
3set_task_perms(caller_perms());
4r = args[1..1];
5suspend = (length(args) > 1) ? args[2] | 0;
6i = 1;
7while (i <= length(r))
8if (kids = children(r[i]))
9r[i + 1..i] = kids;
10i = i + 1;
11else
12r[i..i] = {};
13endif
14$command_utils:suspend_if_needed(suspend);
15endwhile
16return r;

disown disinherit

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":disown(object) / :disinherit(object)";
2" => 1 (for a successful disinheritance)";
3" raises E_PERM, E_INVARG, E_ARGS";
4cp = caller_perms();
5"     no set_task_perms() because we need to be able to";
6"     chparent() an object we don't own";
7{victim} = args;
8parent = parent(victim);
9if ($perm_utils:controls(cp, victim))
10raise(E_INVARG, tostr(victim.name, " (", victim, ") is yours.  Use @chparent."));
11elseif (!valid(parent))
12raise(E_INVARG, tostr(victim.name, " (", victim, ") is already an orphan."));
13elseif (!$perm_utils:controls(cp, parent))
14raise(E_PERM, tostr(parent.name, " (", parent, "), the parent of ", victim.name, " (", victim, "), is not yours."));
15elseif (!valid(grandparent = parent(parent)))
16"... still not sure about this... do we care?  --Rog...";
17raise(E_INVARG, tostr(victim.name, " (", victim, ") has no grandparent to take custody."));
18else
19chparent(victim, grandparent);
20return 1;
21endif

accessible_verbs

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1"  accessible_verbs(object)   => a list of verb names (or E_PERM) regardless of readability of object";
2set_task_perms(caller_perms());
3thing = args[1];
4verbs = {};
5i = 1;
6while ((info = `verb_info(thing, i) ! ANY') != E_VERBNF)
7verbs = {@verbs, info ? info[3] | E_PERM};
8i = i + 1;
9endwhile
10return verbs;

fertile_kids

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1what = args[1];
2kids = {};
3for x in (children(what))
4if (x.f || children(x))
5kids = setadd(kids, x);
6endif
7endfor
8return kids;

has_a

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":has_a(LIST object-list, OBJ object-type)";
2"If there's a descendant of object-type in object-list, return it, otherwise #-1.";
3for x in (args[1])
4if ($ou:isa(x, args[2]))
5return x;
6endif
7endfor
8return #-1;

fertile_branches

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":fertile_branches(OBJ what [, LIST got])";
2"Return all kids & grandkids that are fertile.";
3if (length(args) > 1)
4got = args[2];
5else
6got = {};
7endif
8what = args[1];
9for x in (children(what))
10$cu:sin();
11if (x.f)
12got = {@got, x};
13got = {@got, @this:fertile_branches(x)};
14endif
15endfor
16return got;

verb_name

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1{verb_name} = args;
2verb_name = $su:explode(verb_name)[1];
3if (star = index(verb_name, "*"))
4verb_name = verb_name[1..star - 1];
5endif
6return verb_name;

fertile_kids_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1what = args[1];
2kids = {};
3for x in (children(what))
4if (x.f || children(x))
5kids = setadd(kids, x);
6endif
7$cu:sin(2);
8endfor
9return kids;

fertile_descendants_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1s = {};
2what = args[1];
3for x in (children(what))
4$cu:sin();
5if (x.f)
6s = listappend(s, x);
7s = {@s, @this:(verb)(x)};
8endif
9endfor
10return s;

objects_with_verb

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1{findstr, ?from = #-1} = args;
2if (typeof(findstr) != STR)
3raise(E_INVARG, "findstr (arg 1) must be string");
4elseif (typeof(from) != OBJ)
5raise(E_INVARG, "from (arg 2) must be object");
6endif
7results = {};
8if (from)
9for o in ($ou:descendants_suspended(from))
10if (`verb_info(o, findstr) ! ANY => {}')
11results = {@results, o};
12endif
13$cu:sin();
14endfor
15else
16for o in [#0..max_object()]
17if (`verb_info(o, findstr) ! ANY => {}')
18results = {@results, o};
19endif
20$cu:sin();
21endfor
22endif
23return results;

tree_properties

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":tree_properties(OBJ from, STR propname) => an alist of values of properties of objects descended from 'from'.";
2" => { {OBJ a, ANY a.propname}, {OBJ b, ANY b.propname}, ... }";
3{from, propname} = args;
4if (propname == "")
5raise(E_INVARG);
6return {};
7endif
8result = {};
9togo = {from};
10try
11from.(propname);
12except e (E_PROPNF)
13raise(E_PROPNF, tostr(from, " does not define .", propname));
14return {};
15endtry
16while (togo)
17o = togo[1];
18try
19result = {@result, {o, o.(propname)}};
20togo = {@togo, @children(o)};
21except e (ANY)
22"oh well";
23endtry
24togo = togo[2..$];
25$cu:sin();
26endwhile
27return result;

siblings

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1target = args[1];
2return setremove(children(parent(target)), target);

limited_children

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1{OBJ, n} = args;
2if (n)
3children = children(OBJ);
4return $lu:append(children, @$lu:map_arg(this, verb, children, n - 1));
5else
6return {};
7endif

limited_children_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1{OBJ, n} = args;
2$cu:sin();
3if (n)
4children = children(OBJ);
5return $lu:append(children, @$lu:map_arg(this, verb, children, n - 1));
6else
7return {};
8endif

has_verb_and_args

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":has_verb_and_args(OBJ o, STR verb, STR arg, STR arg, STR arg) => 1|0";
2{o, v, dstr, astr, istr} = args;
3try
4verbargs = verb_args(o, v);
5return {dstr, astr, istr} == verbargs;
6except e (E_VERBNF)
7return 0;
8endtry

property_definer

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":property_defined(OBJ an object with the prop, STR propname) => OBJ which actually defines said prop. #-1 for built in props.";
2{object, pname} = args;
3if (pname in $code_utils.builtin_props)
4return #-1;
5endif
6for o in ({@$lu:reverse($ou:ancestors(object)), object})
7if (`property_info(o, pname) ! E_PROPNF')
8return o;
9endif
10endfor
11raise(E_PROPNF);

is_in_a

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1return is_in_a(@args);

treesize

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1{parent} = args;
2todo = children(parent);
3size = 0;
4while (todo)
5o = todo[1];
6size = size + object_bytes(o);
7todo = {@todo[2..$], @children(o)};
8yield;
9endwhile
10return size;

is_true

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1"is_true(OBJ, STR or LIST prop ref)";
2"This little util is specifically for use with $list_utilities:remove_*. Does the obvious.";
3{object, prop} = args;
4ref = object;
5if (typeof(prop) == LIST)
6for p in (prop)
7ref = ref.(p);
8endfor
9else
10ref = object.(prop);
11endif
12return !(!ref);

bf_op

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":bf_op(OBJ, STR or LIST prop ref, STR builtin function, arg, arg, ...)";
2"This is to allow $lu:remove_* to perform functions on properties of the objects in the list given without corrupting the original list for the results.";
3{object, prop, func, @fargs} = args;
4if (typeof(prop) == LIST)
5for p in (prop)
6object = object.(p);
7endfor
8else
9object = object.(prop);
10endif
11return !(!$bf:(func)(object, @fargs));

bf_op_eq_to bf_op_equal_to bf_op_eq bf_op_greater_than bf_op_gt bf_op_less_than bf_op_lt bf_op_not_equal_to bf_op_ne bf_op_greater_than_eq bf_op_ge bf_op_less_than_eq bf_op_le

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":bf_op(OBJ, STR or LIST prop ref, STR builtin function, ANY val to compare, arg, arg, ...)";
2"Same as this:bf_op except that it checks if the result is equivalent to, greater than, less than, etc. a given value. More shit for $lu:remove_*.";
3{object, prop, func, val, @fargs} = args;
4if (typeof(prop) == LIST)
5for p in (prop)
6object = object.(p);
7endfor
8else
9object = object.(prop);
10endif
11ref = `$bf:(func)(object, @fargs) ! ANY';
12if (verb in {"bf_op_equal_to", "bf_op_eq", "bf_op_eq"})
13return ref == val;
14elseif (verb in {"bf_op_not_equal_to", "bf_op_ne"})
15return ref != val;
16elseif (verb in {"bf_op_greater_than", "bf_op_gt"})
17return ref > val;
18elseif (verb in {"bf_op_less_than", "bf_op_lt"})
19return ref < val;
20elseif (verb in {"bf_op_greater_than_eq", "bf_op_ge"})
21return ref >= val;
22elseif (verb in {"bf_op_less_than_eq", "bf_op_le"})
23return ref <= val;
24endif

less_than_eq greater_than_eq greater_than less_than equal_to eq le gt ge lt not_equal_to ne

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":verb(OBJ, STR or LIST prop ref, ANY value to compare against)";
2"Another little util for use with $lu:remove_*. Checks if an object's property is equal to, greater than, less than, etc. to a given value. Obviously the greater than/less than varieties have type constraints.";
3{object, prop, val} = args;
4ref = object;
5if (typeof(prop) == LIST)
6for p in (prop)
7ref = ref.(p);
8endfor
9else
10ref = $code_utils:verb_or_property(object, prop);
11endif
12if (verb in {"equal_to", "eq"})
13return ref == val;
14elseif (verb in {"not_equal_to", "ne"})
15return ref != val;
16elseif (verb in {"greater_than", "gt"})
17return ref > val;
18elseif (verb in {"less_than", "lt"})
19return ref < val;
20elseif (verb in {"greater_than_eq", "ge"})
21return ref >= val;
22elseif (verb in {"less_than_eq", "le"})
23return ref <= val;
24endif

verb_definer

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":verb_definer(OBJ, STR verbname [, INT original definer]) => OBJ definer of verb.";
2"By default returns the original definer or #-1 if undefined. If the third argument is given as 0, it will return the nearest defining object.";
3{o, v, ?top = 1} = args;
4while (valid(o))
5if (`verb_info(o, v) ! E_VERBNF')
6if (((!valid(p = parent(o))) || (!top)) || (!has_callable_verb(p, v)))
7return o;
8else
9o = p;
10endif
11else
12o = parent(o);
13endif
14endwhile
15return o;

children_hash ch

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1h = [];
2{what} = args;
3for c in (children(what))
4for n in ({c.name, @`c.aliases ! ANY => {}'})
5h[n] = c;
6endfor
7endfor
8return h;

property_hash

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1{what} = args;
2h = [];
3for p in (properties(what))
4h[p] = what.(p);
5yield;
6endfor
7return h;

reverse_property_hash rph

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1{what} = args;
2h = [];
3for p in (properties(what))
4val = what.(p);
5if (!(typeof(val) in {STR, OBJ, INT, ERR, FLOAT}))
6continue;
7endif
8h[val] = p;
9yield;
10endfor
11return h;

propgrep

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1"$ou:propgrep(LIST objs, STR property, ANY thing_to_match) => LIST matching_objs";
2" for example: $ou:propgrep(children($wiz), \"name\", \"Seraph\") => {#7195}";
3{objs, propname, match} = args;
4hits = {};
5for o in (objs)
6p = `o.(propname) ! E_PROPNF';
7if (typeof(p) == LIST)
8if (match in p)
9hits = {@hits, o};
10endif
11else
12if (p == match)
13hits = {@hits, o};
14endif
15endif
16yield;
17endfor
18return hits;

map_leaves_suspended

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":map_leaves_suspended(OBJ parent, OBJ verbloc, STR verbname [, LIST extraverbargs [, INT yieldtime]])";
2" => LIST of the results of calling verbloc:verbname(leaf, @extraverbargs) for each leaf of parent.";
3" (hopefully) faster than getting the leaves and calling the verb each time yourself.";
4" NOTE: If verbloc is #-1, then it calls the verb on each leaf!";
5{parent, vo, vname, ?extra_args = {}, ?ytime = 0} = args;
6leaves = {parent};
7results = {};
8while (leaves)
9{l, @leaves} = leaves;
10if (kids = children(l))
11leaves = {@kids, @leaves};
12else
13if (!valid(vo))
14results = {@results, l:(vname)(l, @extra_args)};
15else
16results = {@results, vo:(vname)(l, @extra_args)};
17endif
18endif
19yield ytime;
20endwhile

map_leaves

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

none

Source

1":map_leaves(OBJ parent, OBJ verbloc, STR verbname [, LIST extraverbargs])";
2" => LIST of the results of calling verbloc:verbname(leaf, @extraverbargs) for each leaf of parent.";
3" (hopefully) faster than getting the leaves and calling the verb each time yourself.";
4" NOTE: If verbloc is #-1, then it calls the verb on each leaf!";
5{parent, vo, vname, ?extra_args = {}} = args;
6leaves = {parent};
7results = {};
8while (leaves)
9{l, @leaves} = leaves;
10if (kids = children(l))
11leaves = {@kids, @leaves};
12else
13if (!valid(vo))
14results = {@results, l:(vname)(l, @extra_args)};
15else
16results = {@results, vo:(vname)(l, @extra_args)};
17endif
18endif
19endwhile

fastfind

Spec this none thisFlags rxdOwner #361Definer #45

Referenced by

Source

1":fastfind(OBJ what, STR search [, INT fertile_only]) => matching child of what with 'search' as a name or alias.";
2{what, search, ?fertile_only = 0} = args;
3objs = {what};
4while (objs)
5{o, @objs} = objs;
6yield;
7if (!gamevalid(o))
8continue;
9endif
10if (kids = children(o))
11objs = {@kids, @objs};
12endif
13if (fertile_only && (!valid(first_child(o))))
14continue;
15endif
16if (search in {o.name, o:name(), @o.aliases})
17return o;
18endif
19endwhile
20return #-3;