Caled wrote:From reading the help files, I believe this trigger type is similar to the one zmud/cmud calls an "expression" trigger type. That is, rather than firing on a line from the mud output, it fires when its expression evaluates to be true.
I've played around with it, and read the help files, but I can't get a clear idea on how to make this work as I want it to, though. (Part of my problem is still with just learning the lua of course).
Code: Select all
Pattern: if eqBal_check() = true
Command:
raiseEvent( "onEqBal" , pstats , eqbal , armb )
Script:
Code: Select all
function eqBal_check()
if eqBal="eb" and armb="lr" then
return true
else
return false
end
end
Sorry to be asking more questions, I promise I'm doing my best with the help files first though. I want to raise the "onEqBal" event whenever the "armb" and "eqbal" variables indicate I am fully balanced. I think that something like what I have should do that, but I think I'm getting the trigger quite wrong.
No problem that you ask questions. Mudlet is still in the making and there will definitely be more people who have the same difficulties, but who are too afraid to ask questions. This forum is intended as a permanent source of information. I'm currently assembling the manual so it's a good time to ask with respect to the manual, so I can see where I need to clarify things more or give more detailed information.
For expression triggers to work you need to compile Mudlet yourself from the latest git sources.
For Ubuntu users this is very simple.
You find instructions here:
http://mudlet.sourceforge.net/wordpress/?page_id=30
Lua function conditions can be used as expression triggers if you put your expression in a free function (-> Trigger Editor -> Scripts) that returns a truth value (true or false). Then the trigger will fire when this functions returns true e.g. if you have gained balance.
The simplest solution would be: to make the trigger a multi-condition AND trigger and use 2 Lua expression:
Lua function condition #1:
return eqBal == "eb"
Lua function condition #2:
return armb == "lr"
and as script:
raiseEvent( ....)
another solution would be:
Lua function condition:
eqBal_check()
free function defined in some script item:
Code: Select all
function eqBal_check()
if eqBal == "eb" then
if armb == "lr" then
return true
end
end
return false
end
The operators "and" and "or" in Lua do *NOT* return boolean values. They behave differently. Have a look here:
http://lua-users.org/wiki/ExpressionsTutorial
The second issue is:
Command:
raiseEvent( "onEqBal" , pstats , eqbal , armb )
The "send text" field (formerly called command) sends its content as plain text as is. If you put Lua code in there it will not be executed but sent to the MUD as is.
Consequently, you'd want to put your rainseEvent() call into the trigger script instead.
Using events is much superior to using lua function conditons as expression conditions on a general basis as it's
a lot faster and generally helps improve your system design as it decouples the event generator from the event recievers and thus greatly simplifies system creation as the event sender doesn't have to care about if or how the event is being processed.
I haven't yet arrived at the event section of the manual, but you find some info on how to declare event handlers in the lua api table on raiseEvent() and I've made an simple example that uses events in my Achaea inline map demo script. When you have compiled the latest sources yourself you can download the improved second version of the script and experiment. It should work for you now.