Difference between revisions of "Command:AddTrigger"
Jump to navigation
Jump to search
(7 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
AddTrigger <function> <match text> | AddTrigger <function> <match text> | ||
− | == | + | == Forms == |
+ | *AddTrigger <function> <match text''*''> - Script only command, will execute <function> when <text> is matched. Default reads console text, reading specific text from games requires help from extensions. | ||
== Examples == | == Examples == | ||
+ | function RegisterEvents() | ||
+ | { | ||
+ | ; Add each event | ||
+ | AddTrigger MyTrigger "@WHO@ kills YOU." | ||
+ | AddTrigger YouHit "You hit @WHO@ for @DAMAGE@ point@s@ of damage" | ||
+ | } | ||
+ | |||
+ | function main() | ||
+ | { | ||
+ | call RegisterEvents | ||
+ | do | ||
+ | { | ||
+ | if !${QueuedCommands} | ||
+ | WaitFrame | ||
+ | else | ||
+ | ExecuteQueued | ||
+ | } | ||
+ | while 1 | ||
+ | } | ||
+ | |||
+ | ;AddTrigger MyTrigger "@WHO@ kills YOU." | ||
+ | function MyTrigger(string Line, string Who) | ||
+ | { | ||
+ | Speak -sync You have been killed by ${Who} | ||
+ | } | ||
+ | |||
+ | ;AddTrigger YouHit "You hit @WHO@ for @DAMAGE@ point@s@ of damage" | ||
+ | function YouHit(string Line, string Who, int Damage) | ||
+ | { | ||
+ | ; Note that this function only has 3 parameters. the "s" value from the trigger will be ignored! | ||
+ | Speak You hit ${Who} for ${Damage} damage | ||
+ | } | ||
== See Also == | == See Also == | ||
+ | *[[LavishScript:Triggers|Triggers]] | ||
*[[LavishScript:Commands|LavishScript Commands]] | *[[LavishScript:Commands|LavishScript Commands]] | ||
− | + | ||
{{Command-Stub}} | {{Command-Stub}} | ||
+ | [[Category:LavishScript]] | ||
+ | [[Category:LavishScript Commands]] |
Latest revision as of 15:40, 7 May 2012
Contents
Syntax
AddTrigger <function> <match text>
Forms
- AddTrigger <function> <match text*> - Script only command, will execute <function> when <text> is matched. Default reads console text, reading specific text from games requires help from extensions.
Examples
function RegisterEvents() { ; Add each event AddTrigger MyTrigger "@WHO@ kills YOU." AddTrigger YouHit "You hit @WHO@ for @DAMAGE@ point@s@ of damage" }
function main() { call RegisterEvents do { if !${QueuedCommands} WaitFrame else ExecuteQueued } while 1 }
;AddTrigger MyTrigger "@WHO@ kills YOU." function MyTrigger(string Line, string Who) { Speak -sync You have been killed by ${Who} }
;AddTrigger YouHit "You hit @WHO@ for @DAMAGE@ point@s@ of damage" function YouHit(string Line, string Who, int Damage) { ; Note that this function only has 3 parameters. the "s" value from the trigger will be ignored! Speak You hit ${Who} for ${Damage} damage }
See Also