Useful Utilities for Programmers #113

Parent #68Owner #29Flags readSource hellcore/hellcore.db

Aliases: Useful Utilities for Programmers

6 verbs · 34 properties · 0 children

Verbs

VerbSpecFlagsDefinerLines
@vloc @findverb @vfindany any anyrxd#11339
_megasubsubthis none thisrxd#11321
@megasub*stituteany any anyrxd#11346
@leavesany any anyrxd#11315
@any none nonerxd#11316
@nnlistany none nonerxd#11313

Properties

PropertyDefinerFlagsOwnerValue
warehouse#68r#29<clear>
help_msg#68rc#29<clear>
feature_verbs#68r#29{}
feature_ok#68r#29<clear>
handed#5rc#29<clear>
wield_msg#5rc#29<clear>
unwield_msg#5rc#29<clear>
size#5rc#29<clear>
look_place_msg#5rc#29<clear>
value#5rc#29<clear>
get_msg#5rc#29<clear>
drop_msg#5rc#29<clear>
get_fail_msg#5rc#29<clear>
junk_ok#5rc#29<clear>
floats#5rc#29<clear>
long_name_msg#5rc#29<clear>
article#5rc#29<clear>
setup_list#5rc#29<clear>
health#5rc#29<clear>
health_max#5rc#29<clear>
min_skill#5rc#29<clear>
skill#5rc#29<clear>
recipe_for#5rc#29<clear>
carried_msg#5rc#29<clear>
aliases#1rc#29{"Useful Utilities for Programmers"}
description#1rc#29<clear>
object_size#1r#29{4166, 1298433815}
hidden_verbs#1rc#29<clear>
phelp_msg#1rc#29<clear>
weight#1rc#29<clear>
owner_verbs#1rc#29<clear>
plural_name#1rc#29<clear>
client_image#1rc#29<clear>
listening#1rc#29<clear>

Ancestry

Ancestors (nearest first): #68 Generic Feature Object#5 generic thing#1 root

Children: none

Call graph

calls n113_0 #113:@vloc n107_43 #107:tell n113_0->n107_43 n20_20 #20:match_player n113_0->n20_20 n20_9 #20:trim n113_0->n20_9 n45_6 #45:ancestors n113_0->n45_6 n48_8 #48:suspend_if_needed n113_0->n48_8 n51_21 #51:find_verb_named n113_0->n51_21 n20_59 #20:name_and_number n113_0->n20_59 n20_3 #20:centre n113_0->n20_3 n1_11 #1:tell_lines n113_0->n1_11 n113_1 #113:_megasubsub n113_1->n113_1 n113_2 #113:@megasub*stitute n113_2->n107_43 n113_2->n113_1 n20_38 #20:explode n113_2->n20_38 n45_1 #45:all_properties n113_2->n45_1 n48_4 #48:yes_or_no n113_2->n48_4 n113_3 #113:@leaves n113_3->n107_43 n113_3->n48_8 n113_3->n20_59 n20_19 #20:match_object n113_3->n20_19 n45_26 #45:leaves_suspended n113_3->n45_26 n20_1 #20:left n113_3->n20_1 n113_4 #113:@ n113_4->n107_43 n113_4->n20_20 n20_16 #20:literal_object n113_4->n20_16 n113_5 #113:@nnlist n113_5->n107_43 n113_5->n20_59 n51_13 #51:parse_propref n113_5->n51_13 n48_0 #48:object_match_failed n113_5->n48_0 n6_6 #6:my_match_object n113_5->n6_6 n31_0 #31:eval n113_5->n31_0

Source

@vloc @findverb @vfind

Spec any any anyFlags rxdOwner #29Definer #113

Referenced by

none

Source

1"@vloc <verbname> [on <player>]";
2"Scans for all occurances of the specified verb on the specified player";
3"If no player is specified, the caller is assumed.";
4if (dobj == $nothing)
5player:tell("Usage: `@vloc <verbname>'");
6return;
7endif
8if (iobj == $nothing)
9who = player;
10else
11who = $string_utils:match_player(iobjstr);
12if ((who == $failed_match) || (who == $ambiguous_match))
13player:tell("`", iobjstr, "' is not a valid or unique player.");
14return;
15endif
16endif
17vname = $string_utils:trim(dobjstr);
18pfobjs = {@$ou:ancestors(who), @$rpg.features_for_everyone, @$rpg.features_for_programmers, @who.features};
19if (is_a(who.location, $room))
20pfobjs = {@$ou:ancestors(who.location), who.location, @pfobjs};
21endif
22pfobjs = listinsert(pfobjs, who);
23final = {};
24for pcheck in (pfobjs)
25$command_utils:suspend_if_needed(1);
26vcheck = $code_utils:find_verb_named(pcheck, vname);
27if (vcheck != 0)
28msg = tostr($string_utils:nn(pcheck));
29final = {@final, msg};
30endif
31endfor
32if (length(final) < 1)
33final = {"[No matches found]"};
34endif
35header = tostr($string_utils:center(tostr((("@vloc run for `" + vname) + "'") + $string_utils:nn(who)), 65, "-"));
36final = listinsert(final, header);
37footer = tostr($string_utils:center(tostr(("End of @vloc run: " + tostr(length(pfobjs))) + " Objects Checked"), 65, "-"));
38final = {@final, footer};
39player:tell_lines(final);

_megasubsub

Spec this none thisFlags rxdOwner #361Definer #113

Referenced by

Source

1{find, repl, original} = args;
2didsub = 0;
3type = typeof(original);
4if (type == LIST)
5result = original;
6for i in [1..length(original)]
7yield;
8{didsubsub, sub_result} = this:_megasubsub(find, repl, original[i]);
9if (didsubsub)
10didsub = 1;
11result[i] = sub_result;
12endif
13endfor
14if (didsub)
15return {1, result};
16endif
17elseif (type == STR)
18result = $su:subst(original, {{find, repl}});
19return {result != original, result};
20endif
21return {0, 0};

@megasub*stitute

Spec any any anyFlags rxdOwner #361Definer #113

Referenced by

none

Source

1args = $su:explode(argstr, "/");
2if (length(args) != 3)
3player:tell("Usage: @megasub one thing/another thing/#12345");
4return;
5endif
6target = toobj(args[3]);
7if (tostr(target) != args[3])
8player:tell("'", args[3], "' is not an object.");
9return;
10endif
11if (!valid(target))
12player:tell(target, " is invalid.");
13return;
14endif
15if ((target.owner != player) && (!player.wizard))
16player:tell("No write permission on ", target, " (must be owner or a wizard.)");
17return;
18endif
19find = args[1];
20repl = args[2];
21to_change = {};
22for p in ($ou:all_properties(target))
23yield;
24original = target.(p);
25if (typeof(original) == HASH)
26player:tell("@megasub: skipping .", p, " - it's a hash");
27continue;
28endif
29{didsub, result} = this:_megasubsub(find, repl, original);
30if (didsub)
31player:tell("@megasub: .", p);
32player:tell("  old: ", toliteral(original));
33player:tell("  new: ", toliteral(result));
34to_change = {@to_change, {p, result}};
35endif
36endfor
37if (!$cu:yes_or_no("@megasub: Commit changes?"))
38player:tell("Aborted.");
39return;
40endif
41for change in (to_change)
42{p, newvalue} = change;
43target.(p) = newvalue;
44yield;
45endfor
46player:tell("Complete.");

@leaves

Spec any any anyFlags rxdOwner #361Definer #113

Referenced by

none

Source

1dobj = $su:match_object(dobjstr, player.location);
2if (!valid(dobj))
3player:tell("@leaves what?");
4return;
5endif
6"if (dobj in {#1, $thing, $actor, $creature, $living, $body, $decal, $exit, $room})";
7"  player:tell(\"I don't think you actually meant to do that. So no.\");";
8"  return;";
9"endif";
10player:tell($ansi.bold_on + "Showing all leaves of ", $su:nn(dobj), "..." + $ansi.reset);
11for x in ($ou:leaves_suspended(dobj))
12player:tell($su:left($su:nn(x), -35), $ansi.reset, " ", $su:left(tostr(x), -10), $ansi.reset, " ", $ansi.yellow, $su:left($su:nn(x.location), -30), $ansi.reset);
13$cu:sin(3);
14endfor
15player:tell("Done.");

@

Spec any none noneFlags rxdOwner #361Definer #113

Referenced by

none

Source

1if (!dobjstr)
2dobj = player;
3elseif (valid(o = $su:literal_object(dobjstr)))
4dobj = o;
5elseif (valid(o = $su:match_player(dobjstr)))
6dobj = o;
7else
8return player:tell("Couldn't match `", dobjstr, "'.");
9endif
10location = dobj.location;
11if (!valid(location))
12return player:tell(dobj:dname(), " is in an invalid location.");
13else
14location:look_self();
15(((!is_a(location, $room)) || (location != player.location)) && has_callable_verb(location, "list_exits")) && location:list_exits(player, 1);
16endif

@nnlist

Spec any none noneFlags rxdOwner #361Definer #113

Referenced by

none

Source

1prop = $code_utils:parse_propref(dobjstr);
2if (!prop)
3return player:tell("That's not a property, or if it is, you typed it wrong, or something.");
4elseif (({name, vname} = prop) && (!$command_utils:object_match_failed(dobj = player:my_match_object(name), name)))
5try
6(caller_perms() == $code_utils:verb_perms()) ? property_info(dobj, vname) | $no_one:eval(tostr("property_info(", dobj, ",\"", vname, "\");"));
7except (E_PERM)
8return player:tell("This property is not readable.");
9except (E_PROPNF)
10return player:tell($string_utils:nn(dobj), " doesn't seem to have a property named `", vname, "'.");
11endtry
12(typeof(stuff = dobj.(vname)) in {OBJ, LIST}) ? player:tell($string_utils:nn(stuff)) | player:tell("This property is not suitable for use with this verb. (Needs to be a list of objects)");
13endif