Difference between revisions of "Command:AddTrigger"

From Lavish Software Wiki
Jump to navigation Jump to search
 
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Syntax ==
 
== Syntax ==
 +
AddTrigger <function> <match text>
  
== Description ==
+
== 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]]
*[[IS:Session#Commands|Inner Space Session Commands]]
+
 
  
 
{{Command-Stub}}
 
{{Command-Stub}}
 +
[[Category:LavishScript]]
 +
[[Category:LavishScript Commands]]

Latest revision as of 15:40, 7 May 2012

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