This function can be used to make your own string macros:
varargs string expandos(string str, object tgt) {
string del = "$";
mapping macros = ([
"N" : (: this_player() ? this_player()->query_cap_name() : "" :),
"T" : (: $(tgt) ? $(tgt)->query_cap_name() : "" :),
"SHORT" : (: query_short() :),
]);
// always double check the input
if (nullp(str)) return "";
if (nullp(tgt)) tgt = 0;
foreach (string mac, mixed f in macros)
str = replace_string(str, del+mac, evaluate(f));
return str;
}
This is very useful for setting up new lib objects with customizable strings. The example includes an optional parameter, this is not really needed if you set your objects up correctly. Any variables used inside a functional (that you don't declare in that functional) must be in the form $(varname). Possible uses for this:
set_long(expandos("A very small $SHORT."));
set_emotes(3, ({ expandos("$N growls.") }), 1);
message("combat", expandos("$N smacks $T across the face!"), environment(this_player()), ({ this_player(), tgt }) );
I know some libs have a built in form of this, but not all do. I hope someone finds this useful.
I release this into the public domain blah blah etc.