building utilities #21

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

Aliases: building, utils

19 verbs · 15 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
make_exitthis none thisrxd#2137
set_namesthis none thisrxd#216
recreatethis none thisrxd#2139
transfer_ownership(useless)this none thisrxd#2113
parse_namesthis none thisrxd#2111
audit_object_categorythis none thisrxd#2110
object_audit_stringthis none thisrxd#2192
do_audit do_prospectusthis none thisrxd#2142
do_audit_itemthis none thisrxd#2118
size_stringthis none thisrxd#2110
init_for_corethis none thisrxd#214
match_cardinal_dirthis none thisrxd#217
opposite_dirthis none thisrxd#217
exit_akathis none thisrxd#217
make_exit_pairthis none thisrxd#2122
make_cliffthis none thisrxd#217
make_doorthis none thisrxd#218
make_stairsthis none thisrxd#2111
make_ladderthis none thisrxd#217

Properties

PropertyDefinerFlagsOwnerValue
classes#21rc#361
list of 12{#6, #3, #55, #133, #54, #5, #68, #37, #24, #30, #72, #62}
class_string#21rc#361
list of 12{"p", "R", "E", "N", "C", "T", "F", "M", "H", "D", "U", "O"}
cardinals#21rc#361
list of 12{{{"east", "e"}, 2}, {{"west", "w"}, 1}, {{"north", "n"}, 4}, {{"south", "s"}, 3}, {{"northeast", "ne", "northe"}, 7}, {{"northwest", "nw", "northw"}, 8}, {{"southwest", "sw", "southw"}, 5}, {{"southeast", "se", "southe"}, 6}, {{"up", "u"}, 10}, {{"down", "d"}, 9}, {{"in"}, 12}, {{"out"}, 11}}
cardinals_to_xyz#21rc#361
list of 10{{{"east", "e"}, {1, 0, 0}}, {{"west", "w"}, {-1, 0, 0}}, {{"north", "n"}, {0, -1, 0}}, {{"south", "s"}, {0, 1, 0}}, {{"northeast", "ne", "northe"}, {1, -1, 0}}, {{"northwest", "nw", "northw"}, {-1, -1, 0}}, {{"southwest", "sw", "southw"}, {-1, 1, 0}}, {{"southeast", "se", "southe"}, {1, 1, 0}}, {{"up", "u"}, {0, 0, -1}}, {{"down", "d"}, {0, 0, 1}}}
help_msg#72rc#361
list of 13{"Verbs useful for building. For a complete description of a given verb, do `help $building_utils:verbname'.", "", "make_exit(spec,source,dest[,don't-really-create]) => a new exit", " spec is an exit-spec as described in `help @dig'", "", "set_names(object, spec) - sets name and aliases for an object", "parse_names(spec) => list of {name, aliases}", " in both of these, spec is of the form", " <name>[[,:]<alias>,<alias>,...]", " (as described in `help @rename')", "", "recreate(object, newparent) - effectively recycle and recreate object", " as a child of newparent"}
aliases#1rc#361{"building", "utils"}
description#1rc#361{"This is the building utilities utility package. See `help $building_utils' for more details."}
object_size#1r#29{19794, 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 n21_0 #21:make_exit n6_9 #6:notify n21_0->n6_9 n20_59 #20:name_and_number n21_0->n20_59 n20_50 #20:char_list n21_0->n20_50 n21_1 #21:set_names n21_0->n21_1 n20_47 #20:from_value n21_0->n20_47 n107_43 #107:tell n21_0->n107_43 n21_4 #21:parse_names n21_1->n21_4 n20_38 #20:explode n21_4->n20_38 n21_2 #21:recreate n103_24 #103:report_error n21_2->n103_24 n57_26 #57:setup_new_object_as n21_2->n57_26 n21_3 #21:transfer_ownership(useless) n17_2 #17:set_owner n21_3->n17_2 n21_6 #21:object_audit_string n21_6->n20_59 n57_9 #57:valid n21_6->n57_9 n20_2 #20:right n21_6->n20_2 n48_8 #48:suspend_if_needed n21_6->n48_8 n21_5 #21:audit_object_category n21_6->n21_5 n21_9 #21:size_string n21_6->n21_9 n45_0 #45:has_property n21_6->n45_0 n45_5 #45:isa n21_6->n45_5 n42_0 #42:controls n21_6->n42_0 n122_8 #122:strip n21_6->n122_8 n20_1 #20:left n21_6->n20_1 n21_9->n20_2 n21_7 #21:do_audit n21_7->n107_43 n21_7->n57_9 n21_7->n48_8 n21_7->n45_0 n21_7->n20_1 n48_4 #48:yes_or_no n21_7->n48_4 n6_37 #6:is_listening n21_7->n6_37 n21_8 #21:do_audit_item n21_7->n21_8 n20_26 #20:group_number n21_7->n20_26 n6_12 #6:linelen n21_7->n6_12 n21_8->n107_43 n21_8->n21_6 n21_8->n6_12 n21_10 #21:init_for_core n1_22 #1:init_for_core n21_10->n1_22 n21_14 #21:make_exit_pair n57_2 #57:_create n21_14->n57_2 n17_26 #17:grant_object n21_14->n17_26

Source

make_exit

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

none

Source

1"make_exit(spec, source, dest[, use-$recycler-pool [, kind]])";
2"";
3"Uses $recycler by default; supplying fourth arg as 0 suppresses this.";
4"Optional 5th arg gives a parent for the object to be created";
5"(i.e., distinct from $exit)";
6"Returns the object number as a list if successful, 0 if not.";
7set_task_perms(caller_perms());
8{spec, source, dest, ?use_recycler, ?exit_kind = $exit} = args;
9exit = player:_create(exit_kind);
10if (typeof(exit) == ERR)
11player:notify(tostr("Cannot create new exit as a child of ", $string_utils:nn(exit_kind), ": ", exit, ".  See `help @build-options' for information on how to specify the kind of exit this command tries to create."));
12return;
13endif
14for f in ($string_utils:char_list(player:build_option("create_flags") || ""))
15exit.(f) = 1;
16endfor
17$building_utils:set_names(exit, spec);
18"exit.source = source;";
19"exit.dest = dest;";
20source_ok = source:add_exit(exit);
21dest_ok = 1;
22move(exit, $nothing);
23via = $string_utils:from_value(setadd(exit.aliases, exit.name), 1);
24if (source_ok)
25player:tell("Exit from ", source.name, " (", source, ") to ", dest.name, " (", dest, ") via ", via, " created with id ", exit, ".");
26if (!dest_ok)
27player:tell("However, I couldn't add ", exit, " as a legal entrance to ", dest.name, ".  You may have to get its owner, ", dest.owner.name, " to add it for you.");
28endif
29return {exit};
30elseif (dest_ok)
31player:tell("Exit to ", dest.name, " (", dest, ") via ", via, " created with id ", exit, ".  However, I couldn't add ", exit, " as a legal exit from ", source.name, ".  Get its owner, ", source.owner.name, " to add it for you.");
32return {exit};
33else
34player:_recycle(exit);
35player:tell("I couldn't add a new exit as EITHER a legal exit from ", source.name, " OR as a legal entrance to ", dest.name, ".  Get their owners, ", source.owner.name, " and ", dest.owner.name, ", respectively, to add it for you.");
36return 0;
37endif

set_names

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1"$building_utils:set_names(object, spec)";
2set_task_perms(caller_perms());
3object = args[1];
4names = this:parse_names(args[2]);
5name = names[1] || object.name;
6return object:set_name(name) && object:set_aliases(names[2]);

recreate

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1":recreate(object,newparent) -- effectively recycle and recreate the specified object as a child of parent.  Returns true if successful.";
2{object, parent} = args;
3who = caller_perms();
4if (!(valid(object) && valid(parent)))
5return E_INVARG;
6elseif (who.wizard)
7"no problemo";
8elseif ((who != object.owner) || ((who != parent.owner) && (!parent.f)))
9return E_PERM;
10endif
11"Chparent any children to their grandparent instead of orphaning them horribly.  Have to do the chparent with wizperms, in case the children are owned by others, so do this before set_task_perms.";
12grandpa = parent(object);
13for c in (children(object))
14chparent(c, grandpa);
15endfor
16if (has_callable_verb(object, "recycle"))
17try
18object:recycle();
19except e (ANY)
20$rpg:report_error(e);
21endtry
22endif
23for item in (object.contents)
24if (!is_player(item))
25move(item, is_a(item, $garbage) ? $recycler | $tomb);
26else
27move(item, $player_start);
28endif
29endfor
30set_task_perms(who);
31chparent(object, #-1);
32for p in (properties(object))
33delete_property(object, p);
34endfor
35for v in (verbs(object))
36delete_verb(object, 1);
37endfor
38$recycler:setup_new_object_as(object, parent);
39return 1;

transfer_ownership(useless)

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

none

Source

1"transfer_ownership(object, oldowner, newowner)";
2"Transfer ownership of object from oldowner to newowner.";
3if (!((caller == this) || caller_perms().wizard))
4return E_PERM;
5endif
6what = args[1];
7if (valid(from = args[2]) && (typeof(from.owned_objects) == LIST))
8from.owned_objects = setremove(from.owned_objects, what);
9endif
10if (valid(to = args[3]) && (typeof(from.owned_objects) == LIST))
11to.owned_objects = setadd(to.owned_objects, what);
12$wiz_utils:set_owner(what, to);
13endif

parse_names

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1"$building_utils:parse_names(spec)";
2"Return {name, {alias, alias, ...}} from name,alias,alias or name:alias,alias";
3spec = args[1];
4if (!(colon = index(spec, ":")))
5aliases = $string_utils:explode(spec, ",");
6name = aliases[1];
7else
8aliases = $string_utils:explode(spec[colon + 1..$], ",");
9name = spec[1..colon - 1];
10endif
11return {name, $list_utils:map_arg($string_utils, "trim", aliases)};

audit_object_category

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1if (is_player(what = args[1]))
2return "P";
3endif
4while (valid(what))
5if (i = what in this.classes)
6return this.class_string[i];
7endif
8what = parent(what);
9endwhile
10return " ";

object_audit_string

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1":object_audit_string(object [,prospectus-style])";
2{o, ?prospectus = 0} = args;
3olen = length(tostr(max_object()));
4if (!$recycler:valid(o))
5return tostr(prospectus ? "          " | "", $quota_utils.byte_based ? "    " | "", $string_utils:right(o, olen), " Invalid Object!");
6endif
7if (prospectus)
8kids = 0;
9for k in (children(o))
10$command_utils:suspend_if_needed(0);
11if (k.owner != o.owner)
12kids = 2;
13break k;
14elseif (kids == 0)
15kids = 1;
16endif
17endfor
18"The verbs() call below might fail, but that's OK";
19"Well, actually it won't cuz we seem to be a wizard.  Since you can get the number of verbs information from @verbs anyway, it seems kind of pointless to hide it here.";
20v = verbs(o);
21if (v)
22vstr = tostr("[", $string_utils:right(length(v), 3), "] ");
23else
24vstr = "      ";
25endif
26if (o.r && o.f)
27r = "f";
28elseif (o.r)
29r = "r";
30elseif (o.f)
31r = "F";
32else
33r = " ";
34endif
35vstr = tostr(" kK"[kids + 1], r, $building_utils:audit_object_category(o), vstr);
36else
37vstr = "";
38endif
39if ($quota_utils.byte_based)
40vstr = tostr(this:size_string(`o.object_size[1] ! ANY => 0'), " ", vstr);
41name_field_len = 26;
42else
43name_field_len = 30;
44endif
45if (valid(o.location))
46loc = ((((o.location.owner == o.owner) ? " " | "*") + "[") + $su:nn(o.location)) + "]";
47elseif ($object_utils:has_property(o, "dest") && $object_utils:has_property(o, "source"))
48if (typeof(o.source) != OBJ)
49source = " <non-object> ";
50elseif (!valid(o.source))
51source = "<invalid>";
52else
53source = o.source.name;
54if (o.source.owner != o.owner)
55source = "*" + source;
56endif
57endif
58if (typeof(o.dest) != OBJ)
59destin = " <non-object> ";
60elseif (!valid(o.dest))
61destin = "<invalid>";
62else
63destin = o.dest.name;
64if (o.dest.owner != o.owner)
65destin = "*" + destin;
66endif
67endif
68srclen = min(length(source), 19);
69destlen = min(length(destin), 19);
70loc = ((" " + source[1..srclen]) + "->") + destin[1..destlen];
71elseif ($object_utils:isa(o, $room))
72loc = "";
73try
74for x in (o.entrances)
75if (((((typeof(x) == OBJ) && valid(x)) && (x.owner != o.owner)) && $object_utils:has_property(x, "dest")) && (x.dest == o))
76loc = ((loc + (loc ? ", " | "")) + "<-*") + x.name;
77endif
78endfor
79except (ANY)
80if ($perm_utils:controls(player, o))
81loc = " BROKEN PROPERTY: .entrances";
82endif
83endtry
84else
85loc = " [Nowhere]";
86endif
87if (length(loc) > 41)
88loc = loc[1..37] + "..]";
89endif
90name = $ansi:strip(o.name);
91namelen = min(length(name), name_field_len - 1);
92return tostr(vstr, $string_utils:right(o, olen), " ", $string_utils:left(name[1..namelen], name_field_len), loc);

do_audit do_prospectus

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1":do_audit(who, start, end, match)";
2"audit who, with objects from start to end that match 'match'";
3":do_prospectus(...)";
4"same, but with verb counts";
5{who, start, end, match} = args;
6pros = verb == "do_prospectus";
7"the set_task_perms is to make the task owned by the player. There are no other security aspects";
8set_task_perms(caller_perms());
9if ((((((start == 0) && (end == toint(max_object()))) && (!match)) && (typeof(who.owned_objects) == LIST)) && (length(who.owned_objects) > 100)) && (!$command_utils:yes_or_no(tostr(who.name, " has ", length(who.owned_objects), " objects.  This will be a very long list.  Do you wish to proceed?"))))
10v = pros ? "@prospectus" | "@audit";
11return player:tell(v, " aborted.  Usage:  ", v, " [player] [from <start>] [to <end>] [for <match>]");
12endif
13player:tell(tostr("Objects owned by ", who.name, " (from #", start, " to #", end, match ? " matching " + match | "", ")", ":"));
14count = bytes = 0;
15if (typeof(who.owned_objects) == LIST)
16for o in (who.owned_objects)
17$command_utils:suspend_if_needed();
18if (!player:is_listening())
19return;
20endif
21if ((toint(o) >= start) && (toint(o) <= end))
22didit = this:do_audit_item(o, match, pros);
23count = count + didit;
24if ((didit && $quota_utils.byte_based) && $object_utils:has_property(o, "object_size"))
25bytes = bytes + o.object_size[1];
26endif
27endif
28endfor
29else
30for i in [start..end]
31$command_utils:suspend_if_needed(0);
32o = toobj(i);
33if ($recycler:valid(o) && (o.owner == who))
34didit = this:do_audit_item(o, match, pros);
35count = count + didit;
36if ((didit && $quota_utils.byte_based) && $object_utils:has_property(o, "object_size"))
37bytes = bytes + o.object_size[1];
38endif
39endif
40endfor
41endif
42player:tell($string_utils:left(tostr("-- ", count, " object", (count == 1) ? "." | "s.", $quota_utils.byte_based ? tostr("  Total bytes: ", $string_utils:group_number(bytes), ".") | ""), player:linelen() - 1, "-"));

do_audit_item

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1":do_audit_item(object, match-name-string, prospectus-flag)";
2{o, match, pros} = args;
3found = match ? 0 | 1;
4names = `{o.name, @o.aliases} ! ANY => {o.name}';
5"Above to get rid of screwed up aliases";
6while (names && (!found))
7if (index(names[1], match) == 1)
8found = 1;
9endif
10names = listdelete(names, 1);
11endwhile
12if (found)
13"From Dred---don't wrap long lines.";
14line = $building_utils:object_audit_string(o, pros);
15player:tell(line[1..min($, player:linelen())] + $ansi.reset);
16return 1;
17endif
18return 0;

size_string

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1size = args[1];
2if (!size)
3return " ???";
4elseif (size < 1000)
5return " <1K";
6elseif (size < 1000000)
7return tostr($string_utils:right(size / 1000, 3), "K");
8else
9return tostr($string_utils:right(size / 1000000, 3), "M");
10endif

init_for_core

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

none

Source

1if (caller_perms().wizard)
2pass();
3this.classes = {$player, $room, $exit, $note, $container, $thing, $feature, $mail_recipient, $generic_help, $generic_db, $generic_utils, $generic_options};
4endif

match_cardinal_dir

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1dir = args[1];
2for x in (this.cardinals)
3if (dir in x[1])
4return x[1][1];
5endif
6endfor
7return "";

opposite_dir

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1dir = args[1];
2for x in (this.cardinals)
3if (dir in x[1])
4return this.cardinals[x[2]][1][1];
5endif
6endfor
7return E_INVARG;

exit_aka

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1dir = args[1];
2for x in (this.cardinals)
3if (dir in x[1])
4return x[1];
5endif
6endfor
7return $failed_match;

make_exit_pair

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1":make_exit_pair(OBJ room1, OBJ room2 [, OBJ exit type])";
2"Make a linked pair of exits connecting the two rooms.";
3room1 = args[1];
4room2 = args[2];
5if (length(args) > 2)
6etype = args[3];
7else
8etype = room1:area().default_exit_type;
9endif
10otype = etype;
11if (valid(etype.otherside_type) && is_a(etype.otherside_type, $exit))
12otype = etype.otherside_type;
13endif
14exit1 = $recycler:_create(etype);
15exit2 = $recycler:_create(otype);
16$wiz_utils:grant_object(exit1, player);
17$wiz_utils:grant_object(exit2, player);
18exit1.otherside = exit2;
19exit2.otherside = exit1;
20exit1:moveto(room1);
21exit2:moveto(room2);
22return {exit1, exit2};

make_cliff

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

none

Source

1":make_cliff(OBJ exit)";
2"Given the cliff-face exit, create a cliff.  Other side will be the high ledge.";
3face = args[1];
4ledge = face.otherside;
5result = face.owner:_chparent(face, #18385);
6result2 = ledge.owner:_chparent(ledge, #12300);
7return result && result2;

make_door

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1":make_door(OBJ exit)";
2"Given one exit, make a door pair from both.";
3parent = (length(args) > 1) ? args[2] | $adoor;
4exit = args[1];
5exit2 = exit.otherside;
6result = exit.owner:_chparent(exit, parent);
7result2 = exit2.owner:_chparent(exit2, parent);
8return result && result2;

make_stairs

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

Source

1":make_door(OBJ exit)";
2"Given the up exit, make a stair pair from both.";
3up = args[1];
4down = up.otherside;
5result = up.owner:_chparent(up, $stairs.parent_up);
6up.aliases = setadd(up.aliases, "up");
7up.aliases = setadd(up.aliases, "u");
8result2 = down.owner:_chparent(down, $stairs.parent_down);
9down.aliases = setadd(down.aliases, "down");
10down.aliases = setadd(down.aliases, "d");
11return result && result2;

make_ladder

Spec this none thisFlags rxdOwner #361Definer #21

Referenced by

none

Source

1":make_cliff(OBJ exit)";
2"Given the lower end exit, create a ladder exit pair.  Other side will be the top of the ladder.";
3bottom = args[1];
4top = bottom.otherside;
5result = bottom.owner:_chparent(bottom, #22513);
6result2 = top.owner:_chparent(top, #20543);
7return result && result2;