Fatal Dimensions
 

TCL-Programs Reference Manual

Contents

Trigger commands

Triggers are functions which select if a trigger is triggered. For example, a trigger with "trig true" is always triggered, a trigger with "trig chance 25" has a 25% chance of being triggered.

Trig Command Reference

bribe exits match trig wordsand
chance give text1 value
compare hpcnt text2 wear

trig bribe <value>
Returns true if trigger value is greater or equal then the given value. This is normally used in the bribe triggers.

trig chance <percentage>
A value between 0 and 99 will be rolled. If value is less then percentage this function returns True, otherwise False.

trig compare [argnum] <text>
Can be used for easy comparisons like:

 trig comp ==0 meaning [trig value]==0
 trig comp =="test" meaning [trig value]=="test"
 trig comp 0 =="test" meaning [trig value 0]=="test"
 trig comp <=26 meaning [trig value]<=26
 trig true Just returns true, to let triggers always be fired. (In the old mobprog system a chance of 100 percent was used)


User contributed notes: trig compare
jodocus@fataldimensions.org
Dec 29th 2001, 12:13
Say in a pre-interpret trigger you want to check is the command used is 'look'. use: trig compare 0 =="look"
Verlag@fataldimensions.org
Jan 3rd 2002, 20:11

proc squeek {} {
  char echoaround Squeek squeek.
}
objtrigger 1 post_interpret { squeek } { trig compare 0 =="north" }
objtrigger 2 post_interpret { squeek } { trig compare 0 =="east" }
objtrigger 3 post_interpret { squeek } { trig compare 0 =="south" }
objtrigger 4 post_interpret { squeek } { trig compare 0 =="west" }
objtrigger 5 post_interpret { squeek } { trig compare 0 =="up" }
objtrigger 6 post_interpret { squeek } { trig compare 0 =="down" }

trig exits <exit> [exit]
Returns true if the exit entered is one of the given exits. You may use number or names. This is normally used in the leave and exit triggers. Example: trig exits north south west up

trig exits 0 2 3

User contributed notes: trig exits
jodocus@fataldimensions.org
Jan 15th 2002, 16:36
proc go_south {} {
! Bye, I am going south (or east)
return true
}
roomtrigger 1 leave {go_south} {trig exits south east }

trig give <objid>
Returns true if the object given matches the objid. This trigger doesn't look at the trigger value, but at the default object. This command is normally used in the give trigger.

trig hpcnt <percentage>
Returns true if the percentage of hitpoints of the mob is below this percentage. This is normally used in hpcnt triggers.

trig match <regexp>
Match a simple regular expression. This is always case insensitive.

trig text1
Returns the $t value from an act trigger.

trig text2
Returns the $T value or $d value from an act trigger.

trig words <words> [...]
Returns true if one of the words has been found in the trigger text. Search is done case independent. Only complete words are found.

Example: The text: This is a test?

trig words this returns true
trig words this a returns true
trig words test? returns true
trig words "this test" returns false
trig words tes returns false


trig value [argnum]
Returns the string, text value of this trigger. If there is no trigger value an error will be generated. The trigger value is also stored in the global variable $::t. This variable will be empty if no trigger value is available. Different triggers have different trigger values. Also a lot of triggers don't have a trigger value at all. The following triggers have the following trigger values:

speech The text spoken.
exit, exall, leave, leall  Number of the exit:

north
east
south
west
up
down

bribe The amount of silver given
hour The hour of the day in the mud.
timer The current timer value

If argnum is specified only one word of the trigger value is returned. (0 means the first word)

trig wear <wear-field>
Returns true if the wear-field of an object is the same as specified in the field. This is normally used in wear or remove object-triggers. See the output of "? wear" for a list of wear-fields.

trig wordsand <words> [...]
Returns true if all the words are found in the trigger text. Order is not important. Search is done case independent.

The trigger expression trig words key please will return true for the following sentences.

 Could you give me the key please?
 Could you please give me the key?
 I want the please key.
 Please, could you give me the key.