
Now, it's noted that all of the command lines to be executed below the triggers are all scripted in Lua, so some functions may be a little confusing at first, but eventually you'll get the hang of it. Here's an example of a successfull variable set from a trigger. Just as when the Alias mentioned above captures everything between the "z" character and the pressing the enter key, triggers can be set to capturing specific lines as well.
#Mudlet triggers code
Setting triggers as a perl regex code is the simplest and most effective way of creating and adjusting variables. Triggers lines can be set to an Exact Match, beginning of line substring, a substring, or a perl regex code. Now when a code comes across your screen saying that "A cat enters the room." you will instantaneously pet the cute little thing! Now, just as aliases are case sensitive Triggers are as well. and set the command to be executed as - send("pet cat"). Triggers are lines of code that you tell the system "if this comes across the screen then execute the command listed below." One can enter into a trigger line - A cat enters the room. The easiest explanation of a trigger in the Mudlet environment is a giant "if/then" statement. The periods before and after the quotations are needed to indicate that the word before, in between of, or after them is a variable and it needs to put it's value there. When using a variable in a Lua script if it's not in a command that is to be sent it can be left alone for further evaluation, like - if target = "Vaxarn" then send("attack ".target). Values can be set to variables by either using aliases or triggers. Basically until you hit the enter key, you're going to set the variable's value to whatever you have just put as the input. So if i entered "z rock" into the input line it would get the value as "rock". var = matches - This would set the variable "var" to the captured value. Not this is useless unless you assign a specified variable to it.įor the regex line listed above the captured line can be set to a variable by using the "matches" function. This captures anything and everything after "z" until i hit the enter key. The Perl Regex line that i use is ^z (\w+)$. One that i use often is my targeting script. Most of the time we tell what value to set to what variable. Variables are items that have values associated with them.
