building utilities #21
Aliases: building, utils
19 verbs · 15 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
make_exit | this none this | rxd | #21 | 37 |
set_names | this none this | rxd | #21 | 6 |
recreate | this none this | rxd | #21 | 39 |
transfer_ownership(useless) | this none this | rxd | #21 | 13 |
parse_names | this none this | rxd | #21 | 11 |
audit_object_category | this none this | rxd | #21 | 10 |
object_audit_string | this none this | rxd | #21 | 92 |
do_audit do_prospectus | this none this | rxd | #21 | 42 |
do_audit_item | this none this | rxd | #21 | 18 |
size_string | this none this | rxd | #21 | 10 |
init_for_core | this none this | rxd | #21 | 4 |
match_cardinal_dir | this none this | rxd | #21 | 7 |
opposite_dir | this none this | rxd | #21 | 7 |
exit_aka | this none this | rxd | #21 | 7 |
make_exit_pair | this none this | rxd | #21 | 22 |
make_cliff | this none this | rxd | #21 | 7 |
make_door | this none this | rxd | #21 | 8 |
make_stairs | this none this | rxd | #21 | 11 |
make_ladder | this none this | rxd | #21 | 7 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
classes | #21 | rc | #361 | list of 12{#6, #3, #55, #133, #54, #5, #68, #37, #24, #30, #72, #62} |
class_string | #21 | rc | #361 | list of 12{"p", "R", "E", "N", "C", "T", "F", "M", "H", "D", "U", "O"} |
cardinals | #21 | rc | #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 | #21 | rc | #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 | #72 | rc | #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 | #1 | rc | #361 | {"building", "utils"} |
description | #1 | rc | #361 | {"This is the building utilities utility package. See `help $building_utils' for more details."} |
object_size | #1 | r | #29 | {19794, 1298433815} |
hidden_verbs | #1 | rc | #361 | <clear> |
phelp_msg | #1 | rc | #361 | <clear> |
weight | #1 | rc | #361 | <clear> |
owner_verbs | #1 | rc | #361 | <clear> |
plural_name | #1 | rc | #361 | <clear> |
client_image | #1 | rc | #361 | <clear> |
listening | #1 | rc | #361 | <clear> |
Ancestry
Ancestors (nearest first): #72 Generic Utilities Package → #1 root
Children: none
Call graph
Source
make_exit
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
Referenced by
- #2:@create line 51:
$bu:set_names - #2:@recreate line 41:
$building_utils:set_names - #6:@rename*# line 64:
$building_utils:set_names - #21:make_exit line 17:
$building_utils:set_names - #49:@untoad line 8:
$building_utils:set_names - #334:ren*ame line 13:
$building_utils:set_names - #334:bpname line 12:
$building_utils:set_names
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
Referenced by
- #2:@recreate line 32:
$building_utils:recreate - #57:_recycle line 28:
$building_utils:recreate - #57:setup_toad line 12:
$building_utils:recreate
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)
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
Referenced by
- #21:set_names line 4:
this:parse_names - #32:why_bad_name line 3:
$building_utils:parse_names
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
Referenced by
- #21:object_audit_string line 35:
$building_utils:audit_object_category
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
Referenced by
- #21:do_audit_item line 14:
$building_utils:object_audit_string
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
Referenced by
- #2:@audit line 17:
$building_utils:do_audit - #50:@pros*pectus line 15:
$building_utils:do_prospectus
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
Referenced by
- #21:do_audit line 22:
this:do_audit_item - #21:do_audit line 34:
this:do_audit_item
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
Referenced by
- #21:object_audit_string line 40:
this:size_string
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
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
Referenced by
- #2:@dig line 6:
$building_utils:match_cardinal_dir - #55:set_aliases line 3:
$building_utils:match_cardinal_dir - #334:dig line 22:
$building_utils:match_cardinal_dir
Source
1dir = args[1]; 2for x in (this.cardinals) 3if (dir in x[1]) 4return x[1][1]; 5endif 6endfor 7return "";
opposite_dir
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
Referenced by
- #2:@dig line 38:
$building_utils:exit_aka - #2:@dig line 43:
$building_utils:exit_aka - #334:dig line 32:
$building_utils:exit_aka - #334:dig line 33:
$building_utils:exit_aka
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
Referenced by
- #2:@digg line 57:
$building_utils:make_exit_pair - #2:@dig line 35:
$building_utils:make_exit_pair - #334:dig line 61:
$building_utils:make_exit_pair
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
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
Referenced by
- #2:@make-door line 6:
$building_utils:make_door - #2:@make-hole line 6:
$building_utils:make_door
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
Referenced by
- #2:@Make-stairs line 28:
$building_utils:make_stairs
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
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;