INFO hooks - about hooks in NannyMUD DESCRIPTION Hooks was added to provide support for: * Global and consistent means of adding custom code to any object. * Allow several wizards to add custom code to an object. * Provide the means for adding and removing the costum code safely. * Be the ONLY solution. It should be the only supported method for providing this functionality. With custom code we mean code that you want to have evaluted when an event happens, an event can be that a monster dies, a player killing a monster, a player or monster walks around and for some reason you want to know when the player/monster does these things. If you haven't understood anything upto know I will suggest you give this up and go back to something simpler. The hook system is all this. It provides, for any object configured for its use, the ability to use a single simple call, and have your code called at the appropriate times. There are three kinds of hooks, though they are treated almost identically: 1/ the blocking hook 2/ the value hook 3/ the notification hook. Block hooks are hooks in which the return values are meaningful; these hooks all has the following syntax: block__hook, like block_die_hook. If you hook, for example, block_die_hook in a monster, then the object you specify will be called when the monster is about to die... and since it's a blocking hook, if you return 1 from your function then the monster will not die. NOTE that the function that gets called in your object is block_die_hook() and it sends along the monster/player trying to kill the monster and the monster itself (in which you have registred the hook). Also value hooks have meaningful return values; these hooks all have the following syntax: value_ _ , like value_hit_player_hook. If you hook, for example, value_hit_player_hook in a monster, then the object you specify will be called when the monster is hit.. and since it is a value hook what you return will somehow effect the event, in this case if you return a number then that number will be added to the damage being done to the monster. NOTE that the function that gets called in your object is value_hit_player_hook() and it sends along an array as containing the amount of damage being done, the monster/player(if any) hitting the monster, as second argument is the monster sent along. The notification hook is the more commonly used hook; return values from these are ignored. It is used when you want your code to be notified of an event. To continue the example with block_die_hook: if none of the block_die_hook hooks abort the kill, then the monster will die normally, and the die_hook hook will be called. The arguments are generally the same for a pair of blocking and notification hooks. The syntax here is generally; _hook. The function called is Help topics available:
COPYRIGHT README banish castle door ed feelings genders general hook key mapsystem prices properties rooms style/ termcap tourist_info water_room_old
[ NannyMuds main page | FAQ | Contact us ] You are guest number 131 since November 2019.
This file was last modified: June 2000.