lima-1.0b5/
lima-1.0b5/driver/
lima-1.0b5/driver/ChangeLog.old/
lima-1.0b5/driver/Win32/
lima-1.0b5/driver/compat/
lima-1.0b5/driver/include/
lima-1.0b5/driver/testsuite/
lima-1.0b5/driver/testsuite/clone/
lima-1.0b5/driver/testsuite/command/
lima-1.0b5/driver/testsuite/data/
lima-1.0b5/driver/testsuite/etc/
lima-1.0b5/driver/testsuite/include/
lima-1.0b5/driver/testsuite/inherit/
lima-1.0b5/driver/testsuite/inherit/master/
lima-1.0b5/driver/testsuite/log/
lima-1.0b5/driver/testsuite/single/
lima-1.0b5/driver/testsuite/single/tests/compiler/
lima-1.0b5/driver/testsuite/single/tests/efuns/
lima-1.0b5/driver/testsuite/single/tests/operators/
lima-1.0b5/driver/testsuite/u/
lima-1.0b5/driver/tmp/
lima-1.0b5/etc/
lima-1.0b5/lib/WWW/help/
lima-1.0b5/lib/cmds/
lima-1.0b5/lib/cmds/create/
lima-1.0b5/lib/cmds/player/attic/
lima-1.0b5/lib/contrib/bboard/
lima-1.0b5/lib/contrib/boards/
lima-1.0b5/lib/contrib/marriage/
lima-1.0b5/lib/contrib/roommaker/
lima-1.0b5/lib/contrib/transient_effect/
lima-1.0b5/lib/daemons/channel/
lima-1.0b5/lib/daemons/imud/
lima-1.0b5/lib/data/
lima-1.0b5/lib/data/config/
lima-1.0b5/lib/data/links/
lima-1.0b5/lib/data/news/
lima-1.0b5/lib/data/players/
lima-1.0b5/lib/data/secure/
lima-1.0b5/lib/domains/
lima-1.0b5/lib/domains/std/2.4.5/maze1/
lima-1.0b5/lib/domains/std/2.4.5/npc/
lima-1.0b5/lib/domains/std/2.4.5/post_dir/
lima-1.0b5/lib/domains/std/2.4.5/sub/
lima-1.0b5/lib/domains/std/camera/
lima-1.0b5/lib/domains/std/config/
lima-1.0b5/lib/domains/std/cult/
lima-1.0b5/lib/domains/std/effects/
lima-1.0b5/lib/domains/std/misc/
lima-1.0b5/lib/domains/std/monsters/
lima-1.0b5/lib/domains/std/recorder/
lima-1.0b5/lib/domains/std/rooms/
lima-1.0b5/lib/domains/std/rooms/beach/
lima-1.0b5/lib/domains/std/rooms/labyrinth/
lima-1.0b5/lib/domains/std/school/
lima-1.0b5/lib/domains/std/school/O/
lima-1.0b5/lib/domains/std/spells/
lima-1.0b5/lib/domains/std/spells/stock-mage/
lima-1.0b5/lib/domains/std/spells/stock-priest/
lima-1.0b5/lib/help/
lima-1.0b5/lib/help/admin/
lima-1.0b5/lib/help/hints/General_Questions/
lima-1.0b5/lib/help/hints/Pirate_Quest/
lima-1.0b5/lib/help/player/
lima-1.0b5/lib/help/player/bin/
lima-1.0b5/lib/help/player/quests/
lima-1.0b5/lib/help/wizard/
lima-1.0b5/lib/help/wizard/coding/guilds/
lima-1.0b5/lib/help/wizard/coding/rooms/
lima-1.0b5/lib/help/wizard/lib/daemons/
lima-1.0b5/lib/help/wizard/lib/lfun/
lima-1.0b5/lib/help/wizard/lib/std/
lima-1.0b5/lib/help/wizard/mudos_doc/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/interactive/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/concepts/
lima-1.0b5/lib/help/wizard/mudos_doc/driver/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/arrays/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/buffers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/compile/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/filesystem/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/floats/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/functions/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/general/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mappings/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mixed/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/numbers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/constructs/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/types/
lima-1.0b5/lib/include/driver/
lima-1.0b5/lib/log/
lima-1.0b5/lib/obj/admtool/
lima-1.0b5/lib/obj/admtool/internal/
lima-1.0b5/lib/obj/admtool/mudinfo/
lima-1.0b5/lib/obj/admtool/secure/
lima-1.0b5/lib/obj/secure/
lima-1.0b5/lib/obj/secure/cmd/
lima-1.0b5/lib/obj/secure/mailers/
lima-1.0b5/lib/obj/secure/shell/
lima-1.0b5/lib/obj/secure/shell/classes/
lima-1.0b5/lib/obj/tasktool/
lima-1.0b5/lib/obj/tasktool/internal/
lima-1.0b5/lib/open/
lima-1.0b5/lib/secure/
lima-1.0b5/lib/secure/cgi/
lima-1.0b5/lib/secure/modules/
lima-1.0b5/lib/secure/simul_efun/
lima-1.0b5/lib/std/adversary/
lima-1.0b5/lib/std/adversary/advancement/
lima-1.0b5/lib/std/adversary/armor/
lima-1.0b5/lib/std/adversary/blows/
lima-1.0b5/lib/std/adversary/death/
lima-1.0b5/lib/std/adversary/formula/
lima-1.0b5/lib/std/adversary/health/
lima-1.0b5/lib/std/adversary/pulse/
lima-1.0b5/lib/std/adversary/wield/
lima-1.0b5/lib/std/classes/event_info/
lima-1.0b5/lib/std/container/
lima-1.0b5/lib/std/living/
lima-1.0b5/lib/std/modules/contrib/
lima-1.0b5/lib/std/patterns/
lima-1.0b5/lib/std/race/
lima-1.0b5/lib/std/race/restricted/
lima-1.0b5/lib/std/room/
lima-1.0b5/lib/tmp/
lima-1.0b5/lib/trans/
lima-1.0b5/lib/trans/admincmds/
lima-1.0b5/lib/trans/obj/
lima-1.0b5/lib/wiz/
 HOOKS - A Tutorial by Lathander
 -------------------------------
 
 Prototypes
 ----------
 varargs mixed call_hooks  (string tag, mixed kind, mixed start, 
                            array args...);
 void          add_hook    (string tag, function hook);
 void          remove_hook (string tag, function hook);
 
 
 Headers
 ----------
 inherit "/std/object/hooks";
 #include <hooks.h>
 
 
    This is just going to be a quick run through the concept and use of 
 hooks.  I hope to make it clear, but if its not, let me know and I'll 
 see if I can clarify it.  
    After inheriting the hooks file, your object now contains a mapping
 of hooks.  There can be as many hooks as you like.  However, all of the
 hooks are grouped into sets with similar 'tag' names.
 
    The first step to setting up a hook is to establish what it will do
 in its local code.  You do this by adding a call_hooks() function.  In
 our example, we'll do a hook that modify's a player's strength.
 
 // Example Code in a player object.
 // This code does not really exist.
 int get_strength() {
    int strength;
 
    strength = 100;
    ...
    strength = call_hooks("modify_strength",HOOK_FILTER,0,strength);
    ...
    return strength;
 }
 
    In this example we're giving each function that has hooked the 
 "modify_strength" tag in this object a chance to modify the player's 
 strength.  This gives us the power of letting other objects modify this 
 object's strength, without them having to touch this object's code.  
 Once a hook is in place, it rarely has to be changed.
    Whenever call_hooks() is called, it, in turn, calls every hook that 
 has been put into this object with a particular tag.
 
    The second step is to insert the actual hook into the object.  In 
 this case, we'll have a set of Guantlets of Ogre Power which will insert 
 a hook into a player to make them stronger when they wear it.
 
    Here's an example for a set of Gauntlets of Ogre Power.  
 
 void eventWear() {
    ::eventWear();
    environment(this())->add_hook("modify_strength", (: ogre_strength :));
    message("event","You feel power course throu your muscles!\n",you());
 }
 
 int ogre_strength(int strength) {
    return strength*11/10;
 }
 
 void eventRemove() {
    ::eventRemove();
    environment( this() )->
       remove_hook("modify_strength",(: ogre_strength :));
    message("event","You suddenly feel wimpy.\n",you());
 }
 
    
    Now, whenever the player puts on the Gauntlets, the add_hook() is 
 called on them.  The add_hook() links the tag "modify_strength" in the 
 wearer with the function ogre_strength() in the gauntlets.  Whenever the 
 wearer's object executes a call_hooks() with the tag "modify_strength" 
 then the ogre_strength() function will get called with the args specified 
 in the call_hooks() function.
    Note that I called remove_hook() when the player took off the 
 guantlets.  Don't forget to remove the hook or you may get very strange 
 results.
 
 mixed kind
 ----------
 
    Now, the call_hooks() function is much more complicated than I made it
 first appear.  The mixed kind parameter to call_hooks() is the key to 
 that.  Here's the possible values of kind, and a description of what 
 they make call_hooks() do.
 
    HOOK_IGNORE - Calls all hooks, but call_hooks() always returns zero.
 
    HOOK_SUM    - Calls all hooks and adds their return values.  The
                  return value of call_hooks() is the sum of the return 
                  values.
 
    HOOK_LAND   - Calls the hooks in a random order.  If *any* of the 
                  hooks returns a zero, then call_hooks() returns a zero.
                  (Logical And)
 
    HOOK_LOR    - Calls the hooks in a random order.  If *any* of the
                  hooks returns a one, then call_hooks() returns a one.
                  (Logical Or)
 
    HOOK_FILTER - Calls all of the hooks in a random order.  The first
                  hook gets the regular args.  For successive functions,
                  however, the first argument is the return value of
                  the previous hook.  call_hooks() returns the value
                  of the last hook.
 
    HOOK_YES_OR_NO - Calls all of the hooks in a random order.  If any
                  function returns a zero or a string, then call_hooks()
                  returns that value and does not process any further
                  hooks.  If all hooks are processed without returning
                  a zero or a string, then a one is returned.
 
    a string    - 'kind' can also be a string.  If it is a string, then
                  the return value of the call_hooks() will be a string
                  with all of the return values of all of the hooks
                  concatenated.  The value of 'kind' will act as a 
                  delimiter between strings.
 
                 
 Return value if there are no hooks.
 -----------------------------------
 
    If call_hooks() is called, but there are currently no hooks into that
 object with the given tag value, then the return value is the same as
 'start'.  In other words, start is the defult return value.
 
 
 9/96 Lathander@Accursed Lands