top of page

Basic things

Mudlet has some things that need explanation as a primer, such as the matches table. It can be confusing to read tutorials wherein they mention parts of scripting and coding that have no context. Here I will try to give a basic primer to help with understanding. I will not talk about Lua specifically in this one.

Glossary

Below is a small list of terms that may help you understand things better.

String: In short, it's words. Anything you put into quotes becomes a string. A string is always what is sent to the game.

send("This is a string")

send(This is not a string)

Table: Tables are coding things that allow for more compact or organized code structure. This is more advanced than this page, but you can check out the Lua tables page if you are interested.

Lua: a powerful and lightweight scripting language that is embedded within Mudlet to make scripting easier. Otherwise you would have to write your code and then do all sorts of complicated code magic (like compiling) to make it work every time you wanted to make any kind of change to a script or even an alias. Trust me, Lua is a much better solution.

Triggers, Aliases, and Macro

Triggers

A trigger is a bit of code that reacts to a line that is received by Mudlet.

To use a trigger, you recreate the line into the trigger editor and then choose what kind of trigger it is.

​

Aliases

An alias is something that you enter into the main input window to complete a task.

Macros

Macros function identically to aliases, but instead of using a command, they are bound to a particular key or set of keys.

  • Substring is a general trigger. It has no parameters for beginning or end and will only ever send the entire string to the matches table. It is not really recommended to use this one unless absolutely necessary as it will fire any time it sees the line, whether there is more to it or not.
     

  • Perl Regex is the most powerful of the choices, but it is also the most complicated. See the regex section of this site for more information.
     

  • Start of line is a trigger line that will only ever match if nothing is before what you input as the trigger.
     

  • Exact match will only match what you put into the trigger box exactly. There can be nothing before or after it and all of the text has to match exactly.

  • Aliases have 4 boxes: Name, Pattern, command, and a big box at the bottom.
     

  • The name field can be anything your heart desires. It has no bearing on the operation of the alias itself (this is true of all three of these sections).
     

  • The pattern you want to use as the alias needs to be in regex (see relevant page on site).
     

  • The command box will send exactly what you enter into that box to the game. Variables and others are not permitted in this box.
     

  • The big box at the bottom is where you would write Lua to set or use variables.

  • Like aliases, macros have four boxes: name, command, key binding, and a big script box at the bottom.
     

  • The name field can be anything your heart desires. It has no bearing on the operation of the alias itself.
     

  • The command box sends exactly what you put into the box to the game verbatim.
     

  • The key binding box is how you set what key you want to use. Click the 'grab new key' box, and press the key(s) you wish to bind. You can modify the keystrokes with CTRL, SHIFT, ALT, or any combination of them.
     

  • The big box at the bottom is where you would write Lua to use variables or make more complicated scripts.

Matches

Mudlet has a sort of internal storage compartment where it stores things that it needs to make it function properly. The matches table is one of these. When you make a trigger with a wildcard (see the regex section of the site) and that trigger fires, anything stored by the wildcard goes to the matches table. Matches[1] is the entire string that was matched, so the whole line itself. Matches[2] is just the information from the first wildcard. Matches[3] is the second, matches[4] is the third and so on to nearly unlimited matches. This same logic also applies to aliases.

Here we are going to make an example alias to use the matches table.

​

We create an alias with a pattern: ^k (\w+)$

In the big script section, we would enter: send("kill "..matches[2])

Now, when we type "k mosr", Mudlet will send "kill mosr" to the server.

 

That is because matches[2] is the first single "variable" that was saved to the matches table. Remember, if we used matches[1], it would be the whole string.

​

Let's pretend that we are using matches[1]. If we do: send("kill "..matches[1]), then when we enter "k mosr", Mudlet will send "kill k mosr'' to the game. This is because matches[1] is the entire string that matched.

bottom of page