Chats

From LSWiki

Revision as of 10:16, 20 January 2007; Msb (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Chat Variables

Here are some escape characters you can use in chats and combat chats.

  • %e, enemy
  • %f, friend
  • %s, source (on chat responses)
  • %p, person, prefers players but will choose an NPC if one isn't around
  • %s, source, i.e. the thing that initiates a response for responses
  • %b, bystander, like someone not involved in combat
  • %h, someone hiding, i.e. someone attacking you other than the person you're attacking

Closures in Chats

There are any number of reasons to use closures in chats. The simplest case is that you want a correct message of the autonomon in question interacting with an object. For example, the fishermen in Hanoma perform various actions directed at their fishing rods.

status fish_command() {
    if(query_attacker() || query_incapacitated())
        return True;
    object rod = locate_name("fishing rod");
    unless(rod)
        return True;
    if(environment(this_object())->query_realm("Hanoma_Dock")) {
        message(({ 0, "expertly", ({ "cast", 0 }), "a line from", ({ 'r', 0, rod }), "off the dock and into the bay" }));
        return True;
    }
    int i = random(10);
    switch(i) {
        case 0  : message(({ 0, ({ "check", 0 }), "the line on", ({ 'r', 0, rod }) })); break;
        case 1  : message(({ 0, "carefully", ({ "examine", 0 }), ({ 'r', 0, rod }) })); break;
        case 2  : message(({ 0, ({ "adjust", 0 }), "the taughtness of the line on", ({ 'r', 0, rod }) })); break;
        case 3  : message(({ 0, ({ "tighten", 0 }), "the knot holding the hook on", ({ 'r', 0, rod }) })); break;
        default : 0; break;
    };
    return True;
}

More complex cases can include varying the response depending on conditions.

Example...

Personal tools