Lua code as functions or lambdas support for tempTriggers

Post Reply
User avatar
Vadi
Posts: 4844
Joined: Sat Mar 14, 2009 3:13 pm

Lua code as functions or lambdas support for tempTriggers

Post by Vadi »

I've added support for having a function in all of the temp*Trigger functions (tempTrigger(), tempColorTrigger(), tempLineTrigger(), tempComplexRegexTrigger(), tempRegexTrigger(), tempBeginOfLineTrigger(), and tempExactMatchTrigger()) as well as raised their error messages up to standard.

If you're keen, try out a preview of it to help us test! Download for macOS, Linux, or Windows.

An example of a function you can now do is:
Code: [show] | [select all] lua
mytriggerID = tempExactMatchTrigger("You have recovered balance on all limbs.", function()
  echo("We matched!")
end)
The nice thing about this is that you can capture local variables or run private functions without having to expose them globally.

Jor'Mox
Posts: 1101
Joined: Wed Apr 03, 2013 2:19 am

Re: Lua code as functions or lambdas support for tempTriggers

Post by Jor'Mox »

If you wanted to use an already created function, it would look like this, right?
id = tempTrigger("stuff", my_function)

User avatar
Vadi
Posts: 4844
Joined: Sat Mar 14, 2009 3:13 pm

Re: Lua code as functions or lambdas support for tempTriggers

Post by Vadi »

Yup

User avatar
Vadi
Posts: 4844
Joined: Sat Mar 14, 2009 3:13 pm

Re: Lua code as functions or lambdas support for tempTriggers

Post by Vadi »

Have you had any luck trying this out?

User avatar
Vadi
Posts: 4844
Joined: Sat Mar 14, 2009 3:13 pm

Re: Lua code as functions or lambdas support for tempTriggers

Post by Vadi »


Post Reply