TCL-Programs Reference Manual

Object Triggers

ObjTrigger Command

The objtrigger command is defined as a separate command.

objtrigger <name> <type> <call> [<trigger>]

Adds a trigger to the object. Use <name> to give the trigger an unique name. Non-unique names will be rejected. Also numbers are allowed names. This name can be used to delete the trigger later. Type is the trigger type, like “drop”, “eat”, “zap”, etc. Trigger types are described later. <call> is an TCL-script that should be executed. Normally this will be the name of a procedure to execute. The <trigger> gives the trigger condition. This should be a TCL command (or script) that returns a boolean. If the boolean is true, the <call> script will be executed. If no trigger condition is given, the call script will always be executed.

The <trigger>-script may generate variables that then can be used in the <call> script. The <trigger> script has also access to all other functionality you would normally have in a TCL-mobprog.

Trigger Types

Triggers are fairly easy to add, but this basic list should hold for most needs. Their names, argument list syntaxes, and translation into more articulate English are given below. Some triggers generate a trigger value. This value can be accessed with the [trig] command or trough the $::t variable. The trig command has a lot of routines for easy access to these trigger values.

object triggers Command Reference

trigger pre_close

Value: -
Default Char: Person or mob going to close the object

Called before the object is closed. If it returns a FALSE, the object will not be be closed.

trigger close

Value: -
Default Char: Person or mob who closes the object

Called when the object has been closed.

trigger pre_drink

Value: -
Default Char: Person or mob going to drink the object

Called before the object is drank. If it returns a FALSE, the object will not be be drunk.

trigger drink

Value: -
Default Char: Person or mob who drinks the object

Called when the object has been drank.

trigger pre_drop

Value: -
Default Char: Person or mob going to drop the object

Called before the object is dropped. If it returns a FALSE, the object will not be be dropped.

trigger drop

Value: -
Default Char: Person or mob who drops the object

Called when the object has been dropped.

trigger pre_eat

Value: -
Default Char: Person or mob going to eat the object

Called before the object is eaten. If it returns a FALSE, the object will not be be eaten.

trigger eat

Value: -
Default Char: Person or mob who ate the object

Called when the object has been eaten.

trigger pre_enter

Value: -
Default Char: Person or mob going to enter the object

Called before a mob/char have entered the object. If it returns a FALSE, the object will not be entered.

trigger enter

Value: -
Default Char: Person or mob which entered the object

Called when a mob/player have entered an object.

trigger pre_get

Value: -
Default Char: Person or mob going to get the object

Called before the object is taken. If it returns a FALSE, the object will not be taken.

trigger get

Value: -
Default Char: Person or mob who got the object

Called when the object has been taken.

trigger pre_getout

Value: -
Default Char: Person or mob going to get an object out of the container

Called before an object is taken out of the container. If it returns a FALSE, the object will not be taken.

trigger getout

Value: -
Default Char: Person or mob who got an object out of the container

Called when an object has been taken out of the container.

trigger pre_give

Value: -
Default Char: Person or mob going to give the object

Called before the object is given to somebody. If it returns a FALSE, the object will not be given away.

trigger give

Value: -
Default Char: Person or mob who gives the object

Called when the object has been given.

trigger pre_hit

Value: -
Default Char: Char wielding the obj

Called before the object has damaged a player. If it returns a FALSE, the attack with this object will not happen. The weapon can be used again in the same round in haste/second/third attack.

trigger hit

Value: -
Default Char: Char wielding the obj

Called when the object has hit somebody.

trigger nohit

Value: miss|parry|dodge|block
Default Char: Char wielding the obj

Called when the obj failed to hit the opponent. Reason for it is in [trig value]. This trigger is NOT preceded by a pre_hit action.

trigger interpret_unknown

Value: The command given by the player.
Default Char: The person who gave the command.

This trigger is tested every time a character has entered a command which wasn't recognized as a valid command.

NOTE: Both mobs and players can trigger this trigger.

trigger pre_interpret

Value: The command given by the player.
Default Char: The person who gave the command.

This trigger is tested when a character is going to execute a valid command but the command hasn't been executed yet. If the procedure returns a TRUE, the command is blocked.

NOTE: Both mobs and players can trigger this trigger.

trigger post_interpret

Value: The command given by the player.
Default Char: The person who gave the command.

This trigger is tested every time a character a valid command is executed.

NOTE: Both mobs and players can trigger this trigger.

trigger load

Value: -
Default Char: -

Happens when an object is loaded and placed into a room, inventory or in another object. Note that this trigger doesn't go off for treasures and objects created during the loading of the player.

trigger canlock

Value: -
Default Char: Person or mob going to lock the object

Called before the object is locked. If it returns a FALSE, the object will not be be locked. This trigger REPLACES the check for a valid key.

trigger pre_lock

Value: -
Default Char: Person or mob going to lock the object

Called before the object is locked. If it returns a FALSE, the object will not be be locked.

trigger lock

Value: -
Default Char: Person or mob who locks the object

Called when the object has been locked.

trigger pre_lookat

Value: -
Default Char: Person or mob going to look at the object

Called before the object is looked at. If it returns a FALSE, the object will not be be looked at. Because of POLA this trigger will also fire when looking at extra-descriptions and the object has no pre_lookat_ed trigger.

trigger pre_lookat_ed

Value: Extra description keyword
Default Char: Person or mob going to look at the extra-description of an object

Called before the object is looked at. If it returns a FALSE, the object will not be be looked at.

trigger lookat

Value: -
Default Char: Person or mob who looked at the object

Called when the object has been looked at.

trigger lookat_ed

Value: Extra description keyword
Default Char: Person or mob who looked at the objects extra-description

Called when the objects extra-description has been looked at. Because of POLA this trigger will also fire when looking at extra-descriptions and the object has no lookat_ed trigger.

trigger pre_lookin

Value: -
Default Char: Person or mob going to look in the object

Called before the object is looked in. If it returns a FALSE, the object will not be be looked in.

trigger lookin

Value: -
Default Char: Person or mob who looked in the object

Called when the object has been looked in.

trigger pre_open

Value: -
Default Char: Person or mob going to open the object

Called before the object is opened. If it returns a FALSE, the object will not be be opened.

trigger open

Value: -
Default Char: Person or mob who opens the object

Called when the object has been opened.

trigger playfilter

Value: full name of the song
Default Char: Person or mob fidling with the jukebox

Called when showing the list of songs in the jukebox. Once for each song. If the trigger returns false the song is hidden from view. [Missing] Also called before the pre_play trigger. If this trigger returns false the jukebox behaves as if the song doesn't exist.

trigger pre_play

Value: full name of the song
Default Char: Person or mob fidling with the jukebox

Called before the jukebox starts a song. If the trigger returns FALSE the song is never started.

trigger play

Value: full name of the song
Default Char: Person or mob fidling with the jukebox

Called when a song is started in a jukebox. The first line of the song appears some time after this trigger.

trigger pre_sleep

trigger pre_rest

trigger pre_sit

trigger pre_stand

Value: -
Default Char: Person or mob using the obj

Called before the mob starts to sleep/rest/sit/stand on the obj. If it returns a FALSE, the mob won't move to the new position.

trigger sleep

trigger rest

trigger sit

trigger stand

Value: -
Default Char: Person or mob using the obj

Called after the mob went to sleep/rest/sit/stand on the obj.

trigger pre_attack

Value: means of starting the fight. Currently one of: bash, dirtkick, trip, tail, kill, murder, backstab, rescue, attack, eyepok e, magic
Default Char: Person initiating the attack

This trigger is called when a mob start combat without using magic. (eg. kill/eyepoke/trip/backstab/....) The second char [char -second] is the mob being attacked.

trigger pre_put

Value: -
Default Char: Person or mob going to put the object

Called before the object is put into something. If it returns a FALSE, the object will not be be put into it.

trigger put

Value: -
Default Char: Person or mob who puts the object

Called when the object has been putted.

trigger pre_putin

Value: -
Default Char: Person or mob going to put an object in the container

Called before something is put in the container. If it returns a FALSE, the object will not be be put into it.

trigger putin

Value: -
Default Char: Person or mob who puts an object into the container

Called when an object has been put into the container.

trigger pre_quaff

Value: -
Default Char: Person or mob going to quaff the object

Called before the object is quaffed. If it returns a FALSE, the object will not be be quaffed.

trigger quaff

Value: -
Default Char: Person or mob who quaffs the object

Called when the object has been quaffed.

trigger pre_recite

Value: -
Default Char: Person or mob going to zap the object/mob

Called before the object is recite. If it returns a FALSE, the scroll will not be be recited. Target of the scroll is stored in -second (either obj or char)

trigger recite

Value: -
Default Char: Person or mob who recited the scroll

Called when the scroll has been recited. Target of the scroll is stored in -second (either obj or char)

trigger pre_remove

Value: -
Default Char: Person or mob going to remove object.

Called before the object is removed. If it returns a FALSE, the object will not be removed.

trigger remove

Value: -
Default Char: Person or mob which removed the object.

Called when the object has been removed.

trigger pre_sell

Value: -
Default Char: Person or mob going to sell the object, and the shopkeeper

Called before the object is sold. If it returns a FALSE, the selling of this object will not be done.

trigger sell

Value: -
Default Char: Person or mob selling the object, and the shopkeeper

Called when the object has been sold.

trigger buy

Value: -
Default Char: Person or mob selling the object, and the shopkeeper

Called when the object has been bought.

trigger pre_speech

Value: The words said
Default Char: Person or mob going to say the words

Called before the words are said. If it returns a FALSE, the words will not be be said.

This only goes for the objects in your inventory, in your equipment and in the room. Not for objects in objects.

trigger speech

Value: The words said
Default Char: Person or mob who said the words

Called when the words have been said.

This only goes for the objects in your inventory, in your equipment and in the room. Not for objects in objects.

trigger sunset

Value: -
Default Char: -

Happens after the message "the sun disappears in the west".

trigger sunrise

Value: -
Default Char: -

Happens after the message "the sun rises in the east".

trigger end_day

Value: -
Default Char: -

Happens after the message "the night has begun."

trigger start_day

Value: -
Default Char: -

Happens after the message "the day has begun."

trigger timer

Value: -
Default Char: -

Every object has a timer, this timer can be started with the obj timer command. Normally you issue an obj timer 0 command to let the timer start counting from 0. Every PULSE_TICK the timer trigger is called. You can use trig compare to check the trigger value.

trigger hour

Value: time of day
Default Char: -

This trigger is tested every hour in MUD time.

trigger random

Value: -
Default Char: -

NOTE: This trigger is checked each PULSE_TICK, even if there are no players in the room but there are in the area. If you want this event to be triggered always, you must set the ACT_UPDATE_ALWAYS flag of the mobile.

trigger delay

Value: -
Default Char: -

NOTE: This trigger is checked every PULSE_TICK and activates when the delay of a object (set with the obj delay command) expires. This trigger can be used to create staged object behavior. See also obj remember. An object can have several delay triggers, but every time the delay timer expires, all the triggers are checked and the first successful one executed.

trigger pre_trap

Value: -
Default Char: Person or mob triggering the trap

Called before the trap is sprung. If it returns a FALSE, the trap will not function. The mud will not report this, the progs need to take care of this if desired.

trigger trap

Value: -
Default Char: Person or mob who triggered the trap

Called when the trap has sprung.

trigger canunlock

Value: -
Default Char: Person or mob going to unlock the object

Called before the object is unlocked. If it returns a FALSE, the object will not be be locked. This trigger REPLACES the check for a valid key.

trigger pre_unlock

Value: -
Default Char: Person or mob going to unlock the object

Called before the object is unlocked. If it returns a FALSE, the object will not be be unlocked.

trigger unlock

Value: -
Default Char: Person or mob who unlocks the object

Called when the object has been unlocked.

trigger pre_use

Value: whatever came behind 'use &lt;obj&gt;'
Default Char: Person or mob going to use the object

Called before the object is used. If it returns a FALSE, the object will not be used.

trigger use

Value: whatever came behind 'use &lt;obj&gt;'
Default Char: Person or mob who uses the object

Called when the object is used. The normal use command doesn't output anything, it completly relies on these triggers for output.

trigger pre_wear

Value: -
Default Char: Person or mob going to wear the object

Called before the object is being worn. If it returns a FALSE, the object will not be be worn.

trigger wear

Value: -
Default Char: Person or mob wearing the object

Called when the object has been worn.

trigger weather

Value: new_state <SP> old_state

Trips every time the weather changes. State is one of 'cloudless', 'cloudy', 'raining', 'lightning'.

trigger pre_zap

Value: -
Default Char: Person or mob going to zap the object/mob

Called before the object is zapped. If it returns a FALSE, the object will not be be zapped. Target of the zap is stored in -second (either obj or char)

trigger zap

Value: -
Default Char: Person or mob who zapped the object/mob

Called when the object has been zapped. Target of the zap is stored in -second (either obj or char)