building utilities #21

Parent #79Owner #2Flags obsolete1, readSource RPG Core/rpgcore-patched.db

Aliases: building utilities, building, utils

10 verbs · 8 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
make_exitthis none thisrxd#2137
set_namesthis none thisrxd#216
recreatethis none thisrxd#2143
parse_namesthis none thisrxd#2111
audit_object_categorythis none thisrxd#2110
object_audit_stringthis none thisrxd#2187
do_audit do_prospectusthis none thisrxd#2142
do_audit_itemthis none thisrxd#2118
size_stringthis none thisrxd#2110
init_for_corethis none thisrxd#214

Properties

PropertyDefinerFlagsOwnerValue
classes#21rc#2
list of 12{#6, #3, #7, #9, #8, #5, #74, #45, #30, #37, #79, #68}
class_string#21rc#2
list of 12{"p", "R", "E", "N", "C", "T", "F", "M", "H", "D", "U", "O"}
help_msg#79rc#2
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"}
key#1c#2<clear>
aliases#1rc#2{"building utilities", "building", "utils"}
description#1rc#2{"This is the building utilities utility package. See `help $building_utils' for more details."}
object_size#1r#36{14685, -1090650497}
html#1rc#2<clear>

Ancestry

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

Children: none

Call graph

calls n21_0 #21:make_exit n6_10 #6:notify n21_0->n6_10 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 n6_18 #6:tell n21_0->n6_18 n21_3 #21:parse_names n21_1->n21_3 n20_38 #20:explode n21_3->n20_38 n55_4 #55:map_arg n21_3->n55_4 n21_2 #21:recreate n52_3 #52:has_callable_verb n21_2->n52_3 n21_5 #21:object_audit_string n63_9 #63:valid n21_5->n63_9 n20_71 #20:redirect_ansi n21_5->n20_71 n21_4 #21:audit_object_category n21_5->n21_4 n21_8 #21:size_string n21_5->n21_8 n52_0 #52:has_property n21_5->n52_0 n52_5 #52:isa n21_5->n52_5 n21_8->n20_71 n21_6 #21:do_audit n21_6->n6_18 n21_6->n63_9 n21_6->n20_71 n21_6->n52_0 n56_4 #56:yes_or_no n21_6->n56_4 n6_72 #6:is_listening n21_6->n6_72 n21_7 #21:do_audit_item n21_6->n21_7 n20_26 #20:group_number n21_6->n20_26 n6_13 #6:linelen n21_6->n6_13 n21_7->n6_18 n21_7->n21_5 n21_7->n6_13 n21_9 #21:init_for_core n1_28 #1:init_for_core n21_9->n1_28

Source

make_exit

Spec this none thisFlags rxdOwner #2Definer #21

Referenced by

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);
18exit.source = source;
19exit.dest = dest;
20source_ok = source:add_exit(exit);
21dest_ok = dest:add_entrance(exit);
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 #2Definer #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 #2Definer #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.";
12"Because this is done before set_task_perms() -- thus with wizard perms -- we save ticks and use chparent() instead of #0:chparent().  This will save many more ticks, if this is an object with many children.";
13grandpa = parent(object);
14for c in (children(object))
15chparent(c, grandpa);
16endfor
17for item in (object.contents)
18if (!is_player(item))
19move(item, #-1);
20else
21move(item, $player_start);
22endif
23endfor
24set_task_perms(who);
25if ($object_utils:has_callable_verb(object, "recycle"))
26object:recycle();
27endif
28chparent(object, #-1);
29for p in (properties(object))
30delete_property(object, p);
31endfor
32for v in (verbs(object))
33delete_verb(object, 1);
34endfor
35chparent(object, parent);
36object.name = "";
37object.r = 0;
38object.f = 0;
39object.w = 0;
40if ($object_utils:has_callable_verb(parent, "initialize"))
41object:initialize();
42endif
43return 1;

parse_names

Spec this none thisFlags rxdOwner #2Definer #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 #2Definer #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 #2Definer #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(ticks_left() < 4000) && suspend(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]), " ", vstr);
41name_field_len = 26;
42else
43name_field_len = 30;
44endif
45if (valid(o.location))
46loc = ((((o.location.owner == o.owner) ? " " | "*") + "[") + o.location.name) + "]";
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 = "";
73for x in (o.entrances)
74if (((((typeof(x) == OBJ) && valid(x)) && (x.owner != o.owner)) && $object_utils:has_property(x, "dest")) && (x.dest == o))
75loc = ((loc + (loc ? ", " | "")) + "<-*") + x.name;
76endif
77(ticks_left() < 4000) && suspend(0);
78endfor
79else
80loc = " [Nowhere]";
81endif
82if (length(loc) > 41)
83loc = loc[1..37] + "..]";
84endif
85namelen = min(length(o.name), name_field_len - 1);
86(ticks_left() < 4600) && suspend(0);
87return tostr(vstr, $string_utils:right(o, olen), " ", $string_utils:left(o.name[1..namelen], name_field_len), loc);

do_audit do_prospectus

Spec this none thisFlags rxdOwner #2Definer #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((ticks_left() < 6000) || (seconds_left() < 3)) && suspend(1);
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((ticks_left() < 6000) || (seconds_left() < 3)) && suspend(1);
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 #2Definer #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())]);
16return 1;
17endif
18return 0;

size_string

Spec this none thisFlags rxdOwner #2Definer #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 #2Definer #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