Geas MUD, enter the Aventure!
Geas Home | Play the Game

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] Object references to interactive objects

If you are looking for a particular player, you could look for him with find_living() and then just make sure it's an interactive object. However, it's a lot quicker to use the efun find_player() that works just the same with the exception that there can only be one player with a given name; if he's in the game you will get the object reference to him and no other.

object *find_player(string name)
    object fat_one;

    fat_one = find_player("fatty");

    if (objectp(fat_one))
        fat_one->catch_msg("Hail thee, bloated one!\n");
        write("Nope, no such luck.\n");

Very often you want to know which player issued the command that led to the execution of a specific function. The efun this_interactive() will return the object reference to that player. If the execution chain was started by an independent non-player object, 0 is returned.

However, more often you're not interested in who actually started the chain, but rather who the object is supposed to direct its attention at. That object is returned by the efun this_player(). In other words, while the object might be expected to turn its attentions (command lists, output messages, object effects etc) to the object given by this_player(), it might be another player given by this_interactive() that actually started the execution chain in the object. The value of this_interactive() can never be manipulated by objects in the game, this_player() on the other hand can be set at will. More about that later.

object this_player();
object this_interactive();
    object tp, ti;

    tp = this_player();
    ti = this_interactive();

    if (objectp(ti))
        if (ti != tp)
            ti->catch_msg("Zapped him!\n");

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ronny Wikh on July, 8 2003 using texi2html