Difference between revisions of "Command:AddTrigger"

From Lavish Software Wiki
Jump to navigation Jump to search
Line 42: Line 42:
 
*[[ISSession:Triggers|Triggers]]
 
*[[ISSession:Triggers|Triggers]]
 
*[[LavishScript:Commands|LavishScript Commands]]
 
*[[LavishScript:Commands|LavishScript Commands]]
 +
*[[IS:Kernel#Commands|Kernel Commands]]
 
*[[IS:Session#Commands|Inner Space Session Commands]]
 
*[[IS:Session#Commands|Inner Space Session Commands]]
 +
  
 
{{Command-Stub}}
 
{{Command-Stub}}
 
[[Category:Inner Space]]
 
[[Category:Inner Space]]
[[Category:Inner Space Session]]
+
[[Category:Inner Space Kernel]]
[[Category:Inner Space Session Commands]]
+
[[Category:Inner Space Kernel Commands]]

Revision as of 04:25, 19 October 2005

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