Manual:Migrating
Migrating to Mudlet
From Nexus
Trigger patterns Lets start with triggers. For translating Nexus patterns into Mudlet, use the following table below. Make sure to set the pattern type in Mudlet to be perl regex, because the default substring works differently.
Mudlet | Nexus | What it does |
---|---|---|
(\w+) | {w} | Match one or more non-whitespace characters (a 'word') |
(\d+) | {d} | Match one or more numeric digits (a number) |
([abc]) | {[abc]} | Match one or more of either 'a', 'b' or 'c'. (a character class) |
([^abc]) | {[^abc]} | Match one or more of anything EXCEPT 'a', 'b', or 'c' |
(.*) | {*} | Match zero or more characters (anything) |
^ | {<} | Match the beginning of a line (not the actual newline character) |
$ | {>} | Match the end of a line (not the actual newline character) |
If you just have a pattern with a {<} and {>} and nothing else, copy the pattern over without the {<}{>} and select the exact match pattern type. For example {<}You sit down.{>} in Nexus would become You sit down. in Mudlet with the pattern type of exact match. This is easier to read and matches way faster! |
Basic scripting
The Nexus way of doing a function is like this: #function stuff it does. In Mudlet, it’s function(stuff it does). Note that if you’d like to give text to a function, you put it inside double or single quotes.
Calling functions
Mudlet | Nexus |
---|---|
<lua> send("hi") echo("Hello to me!") </lua> |
|
If you’d like to use a variable inside text, you’d put it outside the quotes and glue it together with two dots. |
Setting variables
Mudlet | Nexus |
---|---|
<lua> number = 1234 echo("My number is: " .. number.. "\n") echo("the " .. number .. " is in the middle of my text\n") echo(string.format("And here's another - %s - way to format things\n", number)) </lua> |
|
Mudlet | Nexus |
---|---|
<lua> (\w+) kicks you\. badguy = matches[2] echo(badguy .. " kicked me!") </lua> |
|
<lua> alias pattern: ^t (.*)$ alias script: target = matches[2] </lua> |
|
The reason the first match goes into matches[2] and not matches[1] is because matches[1] contains the part of the line that matched your trigger / alias. |
#send hello
#wait 1000
#send hi
#wait 500
#send bye
Mudlet:
<lua>
send("hello")
tempTimer(1, send("hi"))
tempTimer(1.5, send("bye"))
</lua>
ifs in Mudlet
Next are the #if statements. Here’s a table comparing the syntaxes of Nexus and Mudlet:
Mudlet Nexus
if <condition> then <text> end
- if <condition> <text>
- if <condition> { <script> }
- if <condition> { <script> } else { <script> }
- if <condition> { <script> } { <script> }
- if <condition> { <script> } elsif <condition> { <script> }
- if <condition> { <script> } elsif <condition> { <script> } else { <script> }
- Math with Variables
- <variable> = <variablename> <+ - / *> <number or variable>
- #add <variablename> <expression>
- Echo
- echo "text\n" or echo("text\n")
- #echo <text>
- echo "text" or echo("text")
- #echo_ <text>
- Enable Group/Alias/Trigger/Keybinding/Timer
- enableAlias("<group name>"), enableTrigger(), enableKey() or enableTimer()
- #groupon <group name>
- Disable Group/Alias/Trigger/Keybinding/Timer
- disableAlias("<group name>"), disableTrigger(), disableKey() or disableTimer()
- #groupoff <group name>
- Highlight
- selectString (line, 1) bg("<color>") resetFormat()
- #highlight <color>
- Gag
- deleteLine()
- #gag
- Open Url/Links
- openUrl("<url>")*
- #openurl <url>
- Send text to Mud
- send("<stuff>")
- #send <text>
- Send Multiple text to Mud at once
- sendAll("hi", "hello", "bye")
- #send_ hi #send_ hello #send bye
- Variable Setting
- <variable name> = "<text value>"
- #set <variable name> <text value>
- <variable name> = <expression>
- #set <variable name> = <expression>
- Clear Variables
- <variable name> = nil
- #unset <variable name>
- Wait/Timers
- <lua>tempTimer(
- #wait <milliseconds>
Notes to be aware of
To finish off, a couple of points that should be remembered:
- Mudlet does profile snapshots (nexus archives) automatically - to load a different one, select it from the list when connecting
- Mudlet can import and export xml
- Mudlet and Nexus xml formats aren’t compatible
- Mudlet can do nexus graphics, here is a package for - [Achaea], [Lusternia]
- Mudlet has a ton more features such are more speed, less bugs, copy from the normal window, replay logging, color html logging, more powerful scripting, and the list goes on.
From MUSHclient
- Mudlet doesn't use %#'s - uses matches[] instead. "%1" or %1 would be matches[2], "%2" or %2 would be matches[3] and so on
- No variables in trigger patterns - but you can check against your variables in scripts, or lua function pattern types
From CMUD
Changing over to Mudlet requires learning some simple syntax changes and some general concept changes:
In a mudlet trigger for example: Name is just the name you want to use to label the trigger. It doesn't effect the actual firing of the trigger. The trigger fires based on the "pattern" and you can have multiple patterns for a single piece of code. You can also have a multi-line trigger, where the entire trigger must see all the patterns to fire. Example #1 - Using a variable and a temp trigger Cmud: <lua> Pattern: ^A (.*) shard appears and clatters to the ground\.$
Code:
- IF (@autogold) {
- temp {You have recovered balance on all limbs.}
{get shard} } </lua>
Mudlet Example: <lua> Pattern: ^A (.*) shard appears and clatters to the ground\.$
Code: if autogold then shardtrigger = tempTrigger("You have recovered balance on all limbs.)", send("get shard") killTrigger(shardtrigger)) end </lua>
Example #2 - Doing Math: Cmud: <lua> Pattern: ^You put (\d+) gold sovereigns in (.*)\.$
Code:
- ADD goldcounter %1
</lua> Mudlet: <lua> Pattern: ^You put (\d+) gold sovereigns in (.*)\.$
Code: goldcounter = goldcounter + tonumber(matches[2]) </lua>
Example #3 - Replacing Text Cmud <lua> Pattern: ^You raze (\w+) magical shield with (.*)\.$
Code:
- sub {%ansi(yellow,cyan,bold)(*X*)%ansi(white) RAZED %ansi(red)%1's %ansi(white)Shield %ansi(yellow,cyan,bold)(*X*)}
</lua> Mudlet <lua> Pattern: ^You raze (\w+) magical shield with (.*)\.$
Code: deleteLine() cecho("<yellow:cyan>You RAZED " .. matches[2] .. " shield") </lua>
Example #4 - Enable/Disable Classes
Cmud: <lua>
- T+ ClassFolderName
</lua>
Mudlet: <lua> enableAlias("ClassFolderName")
Note: Alias can be an alias, trigger, time, key, etc. You can disable entire classes or just single triggers. </lua>
Example 5 - Multi-action Commands Let's say we create an alias called silly
Cmud: <lua> Pattern: sillyAction
Code: look;ct Hello City;pt Hello Party;laugh
Now in cmud if we called this alias from a trigger or another alias, we would just call sillyAction
</lua> Mudlet: <lua> Pattern: sillyAction
Code: sendAll("look","ct Hello City","pt Hello Party", "laugh") </lua>
Now, in mudlet, if we want to call on that alias, we need to tell mudlet that we want to execute the alias sillyAction rather than sending "sillyAction" directly to the mud. To do that we would do:
<lua> expandAlias("sillyAction") </lua>
Example 6 - Using if statements with and, or and nil.
Cmud Code: <lua>
- IF (@myclass="knight" & !(@pets))
{ say cool } </lua> Mudlet Code: <lua> if myclass == "knight" and not pets then
send("say cool")
end </lua>
Example 7 - Hitting your target OR your first argument. This is for when you want to either hit the person you have targeted, or the name you type.
For example, to kick Das you'd type: kk Das
Or if Das is your target, just typing kk
Cmud: <lua> Pattern: ^kk ?(\w+)?$
- VAR target Das
if (@target) { kick @target } if (%1) { kick %1 } </lua>
Mudlet: <lua> Pattern: ^kk ?(\w+)?$
Code: target = "Das" send("kick "..(matches[2] or target)) </lua> Example #7 - Two Pattern Examples <lua>^rz(?:(.*)|)$ This would let you do rzDas to raze Das for example. </lua> Versus: <lua> ^rz ?(\w+)?$ This would require you to do rz Das with a space between rz and Das. </lua>