Command:AddTrigger

From Lavish Software Wiki
Jump to: navigation, search

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