Difference between revisions of "Manual:Migrating"

From Mudlet
Jump to navigation Jump to search
m (→‎From ZMUD: Link to CMUD)
 
(48 intermediate revisions by 9 users not shown)
Line 1: Line 1:
=Migrating to Mudlet=
+
{{TOC right}}
 +
=From Nexus=
  
==From Nexus==
+
{{note}} The Nexus information seems a bit out of date. Please feel free to add or update with more current instructions.
===Trigger patterns===
+
 
 +
'''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.
 
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.
 +
<table border="1" width="100%">
 +
<th>Mudlet</th>
 +
<th>Nexus</th>
 +
<th>What it does</th>
 +
<tr>
 +
<td>(\w+)</td>
 +
<td>{w}</td>
 +
<td>Match one or more non-whitespace characters (a 'word')</td>
 +
</tr>
 +
<tr>
 +
<td>(\d+)</td>
 +
<td>{d}</td>
 +
<td>Match one or more numeric digits (a number)</td>
 +
</tr>
 +
<tr>
 +
<td>([abc])</td>
 +
<td>{[abc]}</td>
 +
<td>Match one or more of either 'a', 'b' or 'c'. (a character class)</td>
 +
</tr>
 +
<tr>
 +
<td>([^abc])</td>
 +
<td>{[^abc]}</td>
 +
<td>Match one or more of anything EXCEPT 'a', 'b', or 'c'</td>
 +
</tr>
 +
<tr>
 +
<td>(.*)</td>
 +
<td>{*}</td>
 +
<td>Match zero or more characters (anything)</td>
 +
</tr>
 +
<tr>
 +
<td>^</td>
 +
<td>{<} </td>
 +
<td>Match the beginning of a line (not the actual newline character)</td>
 +
</tr>
 +
<tr>
 +
<td>$</td>
 +
<td>{>}</td>
 +
<td>Match the end of a line (not the actual newline character)</td>
 +
</table>   
 +
<table frame="box">
 +
<caption>'''Note:'''</caption>
 +
<td>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!</td>
 +
</table>
  
     
 
<div class="listingblock"><div class="content">
 
      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)
 
</div></div>
 
 
Note
 
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===
+
'''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.
 
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 in Nexus====
+
'''Calling functions'''
 
+
<table border="1" width="100%">
 +
<caption>Calling functions</caption>
 +
<th>Mudlet</th>
 +
<th>Nexus</th>
 +
<tr>
 +
<td>
 +
<syntaxhighlight lang="lua">
 +
send("hi")
 +
echo("Hello to me!")
 +
</syntaxhighlight>
 +
</td>
 +
<td>
 
<code>
 
<code>
 
  #send hi
 
  #send hi
 
  #echo Hello to me!
 
  #echo Hello to me!
 
</code>
 
</code>
 
+
</td>
====Calling functions in Mudlet====
+
</tr>
 
+
</table>
<lua>
+
<table frame="box">
send("hi")
+
<caption>'''Note:'''</caption>
echo("Hello to me!")
+
<td>
</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.
 
If you’d like to use a variable inside text, you’d put it outside the quotes and glue it together with two dots.
 +
</td>
 +
</table>
  
====Setting variables in Nexus====
+
'''Setting variables'''
 
+
<table border="1" width="100%">
 +
<caption>Setting variables</caption>
 +
<th>Mudlet</th>
 +
<th>Nexus</th>
 +
<tr>
 +
<td>
 +
<syntaxhighlight lang="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))
 +
</syntaxhighlight>
 +
<td>
 
<code>
 
<code>
 
  #set number 1234
 
  #set number 1234
Line 48: Line 102:
 
  #echo the $number is in the middle of my text
 
  #echo the $number is in the middle of my text
 
</code>
 
</code>
 +
</td>
 +
</tr>
 +
<table>
  
====Setting variables in Mudlet====
+
'''Wildcards'''
 
 
<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>
 
 
 
====wildcards in Mudlet====
 
  
 
To use the wildcard variable in Nexus, you’d use $1 for the first match, $2 for the second and so on. In Mudlet, the matches[] table contains the matches - and it starts placing the matches from 2. So the Nexus $1 would be matches[2], $2 would be matches[3].
 
To use the wildcard variable in Nexus, you’d use $1 for the first match, $2 for the second and so on. In Mudlet, the matches[] table contains the matches - and it starts placing the matches from 2. So the Nexus $1 would be matches[2], $2 would be matches[3].
  
Nexus:
+
<table border="1" width="100%">
 +
<th>Mudlet</th>
 +
<th>Nexus</th>
 +
<tr>
 +
<td>
 +
<syntaxhighlight lang="lua">
 +
(\w+) kicks you\.
 +
badguy = matches[2]
 +
echo(badguy .. " kicked me!")
 +
</syntaxhighlight>
 +
</td>
 +
<td>
 
<code>
 
<code>
 
  {w} kicks you.
 
  {w} kicks you.
Line 68: Line 127:
 
  #echo $badguy kicked me!
 
  #echo $badguy kicked me!
 
</code>
 
</code>
 
+
</td>
Mudlet:
+
</tr>
<lua>
+
<tr>
(\w+) kicks you\.
+
<td>
badguy = matches[2]
+
<syntaxhighlight lang="lua">
echo(badguy .. " kicked me!")
+
alias pattern: ^t (.*)$
</lua>
+
alias script: target = matches[2]
 
+
</syntaxhighlight>
Another example would be the targetting alias:
+
</td>
 
+
<td>
Nexus:
 
 
<code>
 
<code>
 
  alias name: t
 
  alias name: t
 
  alias script: #set target $1
 
  alias script: #set target $1
 
</code>
 
</code>
 
+
</td>
Mudlet:
+
</tr>
<code>
+
<table>
alias pattern: ^t (.*)$
+
<table frame="box">
alias script: target = matches[2]
+
<caption>'''Note:'''</caption>
</code>
+
<td>
 
 
 
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.
 
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.
 +
</td>
 +
<table>
  
====#wait in Mudlet====
+
'''#wait'''
  
 
In Nexus, a #wait will freeze the script while it’s executing - such that commands after it are delayed. In Mudlet, we use tempTimer which that works a bit differently - it doesn’t freeze the script, but instead makes it so commands a tempTimer is asked to do will get done in the future.
 
In Nexus, a #wait will freeze the script while it’s executing - such that commands after it are delayed. In Mudlet, we use tempTimer which that works a bit differently - it doesn’t freeze the script, but instead makes it so commands a tempTimer is asked to do will get done in the future.
  
 
So the difference is that a tempTimer doesn’t freeze the commands following it at all, everything gets done at once as usual. Just things a tempTimer was asked to do get done in the future.
 
So the difference is that a tempTimer doesn’t freeze the commands following it at all, everything gets done at once as usual. Just things a tempTimer was asked to do get done in the future.
 
+
<table border="1" width="100%">
Nexus script:
+
<th>Mudlet</th>
 +
<th>Nexus</th>
 +
<tr>
 +
<td>
 +
<syntaxhighlight lang="lua">
 +
send("hello")
 +
tempTimer(1, [[send("hi")]])
 +
tempTimer(1.5, [[send("bye")]])
 +
</syntaxhighlight>
 +
</td>
 +
<td>
 
<code>
 
<code>
 
  #send hello
 
  #send hello
Line 106: Line 175:
 
  #send bye
 
  #send bye
 
</code>
 
</code>
 +
</td>
 +
</tr>
 +
</table>
  
Mudlet:
+
'''ifs in 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:
 
Next are the #if statements. Here’s a table comparing the syntaxes of Nexus and Mudlet:
Mudlet Nexus
+
<table border="1" width="100%">
 
+
<th>Mudlet</th>
 +
<th>Nexus</th>
 +
<tr>
 +
<td>
 
if <condition> then <text> end
 
if <condition> then <text> end
+
</td>
 
+
<td>
#if <condition> <text>
+
<nowiki>#if <condition> <text></nowiki>
 
+
<nowiki>#if <condition> { <script> }</nowiki>
#if <condition> { <script> }
+
</td>
 
+
</tr>
 +
<tr>
 +
<td>
 
if <condition> then <script> else <script> end
 
if <condition> then <script> else <script> end
+
</td>
 
+
<td>
#if <condition> { <script> } else { <script> }
+
<nowiki>#if <condition> { <script> } else { <script> }</nowiki>
 
+
<nowiki>#if <condition> { <script> } { <script> }</nowiki>
#if <condition> { <script> } { <script> }
+
</td>
 
+
</tr>
 +
<tr>
 +
<td>
 
if <condition> then <script> elseif <condition> then <script> end
 
if <condition> then <script> elseif <condition> then <script> end
+
</td>
 
+
<td>
#if <condition> { <script> } elsif <condition> { <script> }
+
<nowiki>#if <condition> { <script> } elsif <condition> { <script> }</nowiki>
 
+
</td>
 +
</tr>
 +
<tr>
 +
<td>
 
if <condition> then <script> elseif <condition> then <script> else <script> end
 
if <condition> then <script> elseif <condition> then <script> else <script> end
+
</td>
 +
<td>
 +
<nowiki>#if <condition> { <script> } elsif <condition> { <script> } else { <script> }</nowiki>
 +
</td>
 +
<tr>
 +
</table>
  
#if <condition> { <script> } elsif <condition> { <script> } else { <script> }
 
  
 
Here is the sample side-by-side comparison of how you’d use it:
 
Here is the sample side-by-side comparison of how you’d use it:
Mudlet Nexus
+
<table border="1" width="100%">
 
+
<th>Mudlet</th>
 +
<th>Nexus</th>
 +
<tr>
 +
<td>
 +
<syntaxhighlight lang="lua">
 
-- If foo is true, echo that fact.
 
-- If foo is true, echo that fact.
 
   if foo then echo ("Foo is true!") end -- If foo is true, echo that fact.
 
   if foo then echo ("Foo is true!") end -- If foo is true, echo that fact.
Line 183: Line 266:
 
     end
 
     end
 
   end
 
   end
 +
</syntaxhighlight>
 +
</td>
 +
<td>
 +
<code>
 +
<br>// If $foo is true, echo that fact.
 +
  #if $foo #echo Foo is true!    // If $foo is true, echo that fact.
  
+
<br>// A slight modification of the above that illustrates an 'else' clause.
 
+
<br>// The second form shows that the word 'else' is actually optional too.
// If $foo is true, echo that fact.
+
<br>// (The two lines are functionally the same.)
  #if $foo #echo Foo is true!          // If $foo is true, echo that fact.
 
 
 
// A slight modification of the above that illustrates an 'else' clause.
 
// The second form shows that the word 'else' is actually optional too.
 
// (The two lines are functionally the same.)
 
 
   #if $foo { #echo Foo is true! } else { #echo Foo is false! }
 
   #if $foo { #echo Foo is true! } else { #echo Foo is false! }
 
   #if $foo { #echo Foo is true! } { #echo Foo is false! }
 
   #if $foo { #echo Foo is true! } { #echo Foo is false! }
  
// Illustration of putting more than one statement in a block (also
+
<br>// Illustration of putting more than one statement in a block (also
// spans lines here). Note the if doesn't end until the last '}' is
+
<br>// spans lines here). Note the if doesn't end until the last '}' is
// encountered.
+
<br>// encountered.
 
   #if $foo {
 
   #if $foo {
 
     #echo Foo is true!
 
     #echo Foo is true!
Line 204: Line 288:
 
   }
 
   }
  
// This shows how ifs continue (on 'logical' lines) even though the
+
<br>// This shows how ifs continue (on 'logical' lines) even though the
// blocks in its constituent clauses may have multiple lines. The
+
<br>// blocks in its constituent clauses may have multiple lines. The
// following lines are all _one_ single if statement.
+
<br>// following lines are all _one_ single if statement.
 
   #if $foo > 50 {
 
   #if $foo > 50 {
 
     #echo Foo is big!
 
     #echo Foo is big!
Line 225: Line 309:
 
     }
 
     }
 
   }
 
   }
 +
</code>
 +
</td>
 +
</tr>
 +
</table>
  
====Mudlet equivalents of Nexus functions====
+
'''Mudlet equivalents of Nexus functions'''
  
 
Now that we got the ifs covered, lets go over the Mudlet equivalents of other Nexus functions. Note that this is a direct Nexus→Mudlet comparison; certain functions in Mudlet have much more capability.
 
Now that we got the ifs covered, lets go over the Mudlet equivalents of other Nexus functions. Note that this is a direct Nexus→Mudlet comparison; certain functions in Mudlet have much more capability.
Mudlet Nexus
+
<table border="1" width="100%">
 
+
<th>Mudlet</th>
*Math with Variables
+
<th>Nexus</th>
** <variable> = <variablename> <+ - / *> <number or variable>  
+
<tr>
** #add <variablename> <expression>
+
<td><variable name> = "<text value>"</td>
 
+
<td><nowiki>#set <variable name> <text value></nowiki></td>
*Echo
+
</tr>
** echo "text\n" or echo("text\n")      
+
<tr>
** #echo <text>
+
<td><variable name> = <expression></td>
** echo "text" or echo("text")          
+
<td><nowiki>#set <variable name> = <expression></nowiki></td>
** #echo_ <text>
+
</tr>
 
+
<tr>
*Enable Group/Alias/Trigger/Keybinding/Timer
+
<td><variable name> = nil</td>
** enableAlias("<group name>"), enableTrigger(), enableKey() or enableTimer()  
+
<td><nowiki>#unset <variable name></nowiki></td>
** #groupon <group name>
+
</tr>
 
+
<tr>
*Disable Group/Alias/Trigger/Keybinding/Timer
+
<td><variable> = <variablename> <+ - / *> <number or variable></td>
** disableAlias("<group name>"), disableTrigger(), disableKey() or disableTimer()  
+
<td><nowiki>#add <variablename> <expression></nowiki></td>
** #groupoff <group name>
+
</tr>
 
+
<tr>
*Highlight
+
<td>echo "text\n" or echo("text\n")</td>
** selectString (line, 1) bg("<color>") resetFormat()  
+
<td><nowiki>#echo <text></nowiki></td>
** #highlight <color>
+
</tr>
 
+
<tr>
*Gag
+
<td>echo "text" or echo("text")</td>
** deleteLine()                      
+
<td><nowiki>#echo_ <text></nowiki></td>
** #gag
+
</tr>
 
+
<tr>
*Open Url/Links
+
<td>enableAlias("<group name>")/enableTrigger()/enableKey()/enableTimer()</td>
** openUrl("<url>")*                 
+
<td><nowiki>#groupon <group name></nowiki></td>
** #openurl <url>
+
</tr>
 
+
<tr>
*Send text to Mud
+
<td>disableAlias("<group name>")disableTrigger()disableKey()disableTimer()</td>
** send("<stuff>")                  
+
<td><nowiki>#groupoff <group name></nowiki></td>
** #send <text>
+
</tr>
 
+
<tr>
*Send Multiple text to Mud at once
+
<td>selectString (line, 1) bg("<color>") resetFormat()</td>
** sendAll("hi", "hello", "bye")    
+
<td><nowiki> #highlight <color></nowiki></td>
** #send_ hi #send_ hello #send bye
+
</tr>
 
+
<tr>
*Variable Setting
+
<td>deleteLine()</td>
** <variable name> = "<text value>
+
<td><nowiki>#gag</nowiki></td>
** #set <variable name> <text value>
+
</tr>
** <variable name> = <expression>    
+
<tr>
** #set <variable name> = <expression>
+
<td>openUrl("<url>")</td>
 
+
<td><nowiki>#openurl <url></nowiki></td>
*Clear Variables
+
</tr>
** <variable name> = nil             
+
<tr>
** #unset <variable name>
+
<td>send("<stuff>")</td>
 
+
<td><nowiki>#send <text></nowiki></td>
*Wait/Timers
+
</tr>
** <lua>tempTimer(<time in s>, [[ <lua code to do once time is up> ]])</lua>
+
<tr>
** #wait <milliseconds>
+
<td>sendAll("hi", "hello", "bye")</td>
 +
<td><nowiki>#send_ hi #send_ hello #send bye</nowiki></td>
 +
</tr>
 +
<tr>
 +
<td>tempTimer(<nowiki><time in s></nowiki>, [[ <nowiki><lua code to do once time is up></nowiki> ]])</td>
 +
<td><nowiki>#wait <milliseconds></nowiki></td>
 +
</tr>
 +
</table>
  
====How to call aliases in Mudlet====
+
'''How to call aliases in Mudlet'''
  
 
The typical workflow in Nexus is that you’d define the aliases for yourself to use, and also use aliases for system-related things (things like checking if you’d need to eat a herb, etc).
 
The typical workflow in Nexus is that you’d define the aliases for yourself to use, and also use aliases for system-related things (things like checking if you’d need to eat a herb, etc).
Line 292: Line 387:
  
 
To make a function, you go to the Scripts section, create a new script, and write in your function:
 
To make a function, you go to the Scripts section, create a new script, and write in your function:
 
+
<syntaxhighlight lang="lua">
 
   function <name> ()
 
   function <name> ()
 
     <stuff it does>
 
     <stuff it does>
 
   end
 
   end
 
+
</syntaxhighlight>
 
For example, if we want to make a function that does two things for us at once, we’d do this:
 
For example, if we want to make a function that does two things for us at once, we’d do this:
 
+
<syntaxhighlight lang="lua">
 
   function eat_bloodroot()
 
   function eat_bloodroot()
 
     send ("outr bloodroot")
 
     send ("outr bloodroot")
 
     send ("eat bloodroot")
 
     send ("eat bloodroot")
 
   end
 
   end
 
+
</syntaxhighlight>
 
Then just do this in our alias or trigger to outr and eat bloodroot:
 
Then just do this in our alias or trigger to outr and eat bloodroot:
 
+
<syntaxhighlight lang="lua">
 
   eat_bloodroot()
 
   eat_bloodroot()
 
+
</syntaxhighlight>
 
As mentioned, you can also give things to functions - in this case lets expand the function to eat any herb for us we tell it:
 
As mentioned, you can also give things to functions - in this case lets expand the function to eat any herb for us we tell it:
 
+
<syntaxhighlight lang="lua">
 
   function eat (what)
 
   function eat (what)
 
     send ("outr " .. what)
 
     send ("outr " .. what)
Line 318: Line 413:
 
   eat ("kelp")
 
   eat ("kelp")
 
   eat ("ginseng")
 
   eat ("ginseng")
 
+
</syntaxhighlight>
 
Lastly, functions can also give you data back. One useful example for this is to break down tasks into functions, which will help your code readability:
 
Lastly, functions can also give you data back. One useful example for this is to break down tasks into functions, which will help your code readability:
 
+
<syntaxhighlight lang="lua">
 
   function can_i_stand()
 
   function can_i_stand()
 
     if not paralyzed and not prone and not stunned then
 
     if not paralyzed and not prone and not stunned then
Line 331: Line 426:
 
     send ("stand")
 
     send ("stand")
 
   end
 
   end
 
+
</syntaxhighlight>
===Notes to be aware of===
+
==Notes to be aware of==
  
 
To finish off, a couple of points that should be remembered:
 
To finish off, a couple of points that should be remembered:
Line 338: Line 433:
 
*  Mudlet can import and export xml
 
*  Mudlet can import and export xml
 
*  Mudlet and Nexus xml formats aren’t compatible
 
*  Mudlet and Nexus xml formats aren’t compatible
*  Mudlet can do nexus graphics, here is a package for - [[http://forums.mudlet.org/viewtopic.php?f=6&t=981 Achaea]], [[http://forums.lusternia.com/lofiversion/index.php/t18507.html Lusternia]]
+
*  Mudlet can do nexus graphics, here is a package for - [https://forums.mudlet.org/viewtopic.php?f=6&t=981 Achaea], [https://www.lusternia.com/node/28106 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.
+
*  Mudlet has a ton more features such as 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
 +
* <code>Send()</code> in MUSHclient is called [[Manual:Lua Functions#send|send()]] with a lower S in Mudlet - in Lua, capitalization matters! To send a command without echoing it on the screen, use:
 +
  <syntaxhighlight lang="lua">send("my text", false)</syntaxhighlight>
 +
* While MUSHclient uses [https://www.gammon.com.au/scripts/doc.php?function=AnsiNote AnsiNote] to write colorful text, Mudlet offers different ways as well: [[Manual:Lua Functions#cecho|cecho()]] works with the name of a color. You can find lots of predefined colors with [[Manual:Lua Functions#showColors|showColors()]]. You can also style foreground and background seperately with [[Manual:Lua Functions#fg|fg()]] and [[Manual:Lua Functions#bg|bg()]]. To keep your original ANSI colors, use [[Manual:Lua Functions#ansi2decho|ansi2decho()]]. If you need more colors, [[Manual:Lua Functions#decho|decho()]] will take rgb numbers, [[Manual:Lua Functions#hecho|hecho()]] uses hex codes.
 +
* Mudlet does not offer 'GetConnectDuration()' but you could create a script to connect to the [[Manual:Event_Engine#sysConnectionEvent|connection event]] (and maybe sysDisconnectionEvent) and in that function [[Manual:Mudlet_Object_Functions#createStopWatch|start a stopwatch]] to keep count of how long you've been connected for. See [[Manual:Event Engine]] on how to use events in Mudlet.
 +
* Mudlet does not have lpeg built-in but you can include the lpeg library installed on your system in your lua code. On Windows, you can choose to put the lpeg.dll file into Mudlet's install folder. On macOS that is not possible due to restrictions placed by Apple.
 +
* If you used OnPluginPartialLine to match "partial lines" such as prompts, please note that any type of Mudlet triggers should work with such lines so you can just use them for your purpose. For prompts specifically, try tempPromptTrigger.
 +
* If you used OnPluginTick, you can use a GUI timer in Mudlet for essentially the same functionality.
 +
* If you used OnPluginCommandEntered, you can use a "catch all" alias (with a pattern like "^.+") to send all user commands to your script.
 +
* If you have an existing database you'd like to use and don't want to put it into the profile folder, you can use the standard luaSQL interface to load and use it. Some basic examples can be found at https://keplerproject.github.io/luasql/examples.html
 +
* Line numbers in Mudlet are absolute - lines will not get renumbered when they start getting deleted from the buffer.
 +
 
 +
'''Converting MUSHclient triggers into Mudlet triggers'''
 +
 
 +
The following scripts by Discord user Buck allow you to paste a MUSHclient trigger and automatically have a corresponding Mudlet trigger created.
 +
 
 +
First, create a new script with this:
 +
<syntaxhighlight lang="lua">
 +
TRIGGER_GROUP_NAME = "mushtriggers"
 +
MUSHTRIGGER_PREFIX = "mt_"
 +
 
 +
function getAvailableMushTriggerID()
 +
  local n=1
 +
 
 +
  while exists( MUSHTRIGGER_PREFIX..tostring( n), 'trigger')>0 do
 +
    n=n+1
 +
  end
 +
 
 +
  return MUSHTRIGGER_PREFIX..tostring( n)
 +
end
 +
 
 +
function addMushTrigger( pattern, actions)
 +
  pattern = string.gsub( pattern, '%.', '\\.')
 +
  pattern = string.gsub( pattern, '*', '(.+)')
 +
  actions_regex = string.gsub( actions, '%%(%d)', function(x) return ']]..matches['..tostring(x+1)..']..[[' end)
 +
 
 +
  local id = getAvailableMushTriggerID()
 +
 
 +
  createTriggerGroup( TRIGGER_GROUP_NAME)
 +
  permRegexTrigger(
 +
    id,
 +
    TRIGGER_GROUP_NAME,
 +
    {pattern},
 +
    'for _, cmd in ipairs( splitCommands( [['..actions_regex..']])) do expandAlias( cmd) end')
 +
end
 +
</syntaxhighlight>
 +
 
 +
Also create an alias with this:
 +
 
 +
<syntaxhighlight lang="lua">
 +
-- ^/trigger '([^']+)' (.+)$
 +
local pattern = matches[2]
 +
local actions = matches[3]
 +
 
 +
addMushTrigger(pattern, actions)
 +
 
 +
cecho("<green>New trigger added")
 +
</syntaxhighlight>
 +
 
 +
Now you can transfer your MUSH triggers like so:
  
==From MUSHclient==
+
<syntaxhighlight lang="lua">
 +
/trigger 'A wild * enters the room' hit %1
  
#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
+
/trigger '%d/%dhp %d/%dmn' /checkhealth %1
#No variables in trigger patterns - but you can check against your variables in scripts, or lua function pattern types
+
</syntaxhighlight>
  
==From CMUD==
+
=From CMUD=
 
Changing over to Mudlet requires learning some simple syntax changes and some general concept changes:
 
Changing over to Mudlet requires learning some simple syntax changes and some general concept changes:
  
Line 353: Line 513:
 
'''Example #1 - Using a variable and a temp trigger'''
 
'''Example #1 - Using a variable and a temp trigger'''
 
'''Cmud:'''
 
'''Cmud:'''
<lua>
+
<syntaxhighlight lang="lua">
 
Pattern:
 
Pattern:
 
^A (.*) shard appears and clatters to the ground\.$
 
^A (.*) shard appears and clatters to the ground\.$
Line 362: Line 522:
 
{get shard}
 
{get shard}
 
}  
 
}  
</lua>
+
</syntaxhighlight>
  
 
'''Mudlet Example:'''
 
'''Mudlet Example:'''
<lua>
+
<syntaxhighlight lang="lua">
 
Pattern:  
 
Pattern:  
 
^A (.*) shard appears and clatters to the ground\.$
 
^A (.*) shard appears and clatters to the ground\.$
Line 371: Line 531:
 
Code:
 
Code:
 
if autogold then
 
if autogold then
shardtrigger = tempTrigger("You have recovered balance on all limbs.)", [[send("get shard") killTrigger(shardtrigger)]])
+
shardtrigger = tempTrigger("You have recovered balance on all limbs.", [[send("get shard") killTrigger(shardtrigger)]])
 
end
 
end
</lua>
+
</syntaxhighlight>
  
 
'''Example #2 - Doing Math:'''
 
'''Example #2 - Doing Math:'''
 
'''Cmud:'''
 
'''Cmud:'''
<lua>
+
<syntaxhighlight lang="lua">
 
Pattern:
 
Pattern:
 
^You put (\d+) gold sovereigns in (.*)\.$
 
^You put (\d+) gold sovereigns in (.*)\.$
Line 383: Line 543:
 
Code:
 
Code:
 
#ADD goldcounter %1
 
#ADD goldcounter %1
</lua>
+
</syntaxhighlight>
 
'''Mudlet:'''
 
'''Mudlet:'''
<lua>
+
<syntaxhighlight lang="lua">
 
Pattern:  
 
Pattern:  
 
^You put (\d+) gold sovereigns in (.*)\.$
 
^You put (\d+) gold sovereigns in (.*)\.$
Line 391: Line 551:
 
Code:
 
Code:
 
goldcounter = goldcounter + tonumber(matches[2])
 
goldcounter = goldcounter + tonumber(matches[2])
</lua>
+
</syntaxhighlight>
  
 
'''Example #3 - Replacing Text'''
 
'''Example #3 - Replacing Text'''
 
'''Cmud'''
 
'''Cmud'''
<lua>
+
<syntaxhighlight lang="lua">
 
Pattern:
 
Pattern:
 
^You raze (\w+) magical shield with (.*)\.$
 
^You raze (\w+) magical shield with (.*)\.$
Line 401: Line 561:
 
Code:
 
Code:
 
#sub {%ansi(yellow,cyan,bold)(*X*)%ansi(white) RAZED %ansi(red)%1's %ansi(white)Shield %ansi(yellow,cyan,bold)(*X*)}
 
#sub {%ansi(yellow,cyan,bold)(*X*)%ansi(white) RAZED %ansi(red)%1's %ansi(white)Shield %ansi(yellow,cyan,bold)(*X*)}
</lua>
+
</syntaxhighlight>
 
'''Mudlet'''
 
'''Mudlet'''
<lua>
+
<syntaxhighlight lang="lua">
 
Pattern:
 
Pattern:
 
^You raze (\w+) magical shield with (.*)\.$
 
^You raze (\w+) magical shield with (.*)\.$
Line 410: Line 570:
 
deleteLine()
 
deleteLine()
 
cecho("<yellow:cyan>You RAZED " .. matches[2] .. " shield")
 
cecho("<yellow:cyan>You RAZED " .. matches[2] .. " shield")
</lua>
+
</syntaxhighlight>
  
 
'''Example #4 - Enable/Disable Classes'''
 
'''Example #4 - Enable/Disable Classes'''
  
 
'''Cmud:'''
 
'''Cmud:'''
<lua>
+
<syntaxhighlight lang="lua">
 
#T+ ClassFolderName
 
#T+ ClassFolderName
</lua>
+
</syntaxhighlight>
  
 
'''Mudlet:'''  
 
'''Mudlet:'''  
<lua>
+
<syntaxhighlight lang="lua">
 
enableAlias("ClassFolderName")
 
enableAlias("ClassFolderName")
  
Note: Alias can be an alias, trigger, time, key, etc.  
+
-- Note: Alias can be an alias, trigger (enableTrigger), timer (enableTimer), key (enableKey), etc.  
You can disable entire classes or just single triggers.
+
-- You can disable entire classes or just single triggers.
</lua>
+
</syntaxhighlight>
 +
 
 +
'''Example 5 - Multi-action Commands
 +
Let's say we create an alias called silly
 +
 
 +
Cmud:'''
 +
<syntaxhighlight lang="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
 +
 
 +
</syntaxhighlight>
 +
'''
 +
Mudlet:'''
 +
<syntaxhighlight lang="lua">
 +
Pattern:
 +
sillyAction
 +
 
 +
Code:
 +
sendAll("look","ct Hello City","pt Hello Party", "laugh")
 +
</syntaxhighlight>
 +
 
 +
-- 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:
 +
 
 +
<syntaxhighlight lang="lua">
 +
expandAlias("sillyAction")
 +
</syntaxhighlight>
 +
 
 +
'''Example 6 - Using if statements with and, or and nil.'''
 +
 
 +
'''Cmud Code:'''
 +
<syntaxhighlight lang="lua">
 +
#IF (@myclass="knight" & !(@pets))
 +
{
 +
say cool
 +
}
 +
</syntaxhighlight>
 +
'''
 +
Mudlet Code:'''
 +
<syntaxhighlight lang="lua">
 +
if myclass == "knight" and not pets then
 +
  send("say cool")
 +
end
 +
</syntaxhighlight>
 +
 
 +
'''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:'''
 +
<syntaxhighlight lang="lua">
 +
Pattern: ^kk ?(\w+)?$
 +
#VAR target Das
 +
if (@target) {
 +
kick @target
 +
}
 +
if (%1) {
 +
kick %1
 +
}
 +
</syntaxhighlight>
 +
 
 +
'''Mudlet:'''
 +
<syntaxhighlight lang="lua">
 +
Pattern:
 +
^kk ?(\w+)?$
 +
 
 +
Code:
 +
target = "Das"
 +
send("kick "..(matches[2] or target))
 +
</syntaxhighlight>
 +
'''
 +
Example #7 - Two Pattern Examples'''
 +
<syntaxhighlight lang="lua">^rz(?:(.*)|)$ 
 +
-- This would let you do rzDas to raze Das for example.
 +
</syntaxhighlight>
 +
Versus:
 +
<syntaxhighlight lang="lua">
 +
^rz ?(\w+)?$
 +
-- This would require you to do rz Das with a space between rz and Das.
 +
</syntaxhighlight>
 +
 
 +
'''Example #8 - Repeat Commands a number of times''' with %i functionality, i.e., #12 kill bug %i will send "kill bug 1", "kill bug 2", "kill bug 3"...etc
 +
<syntaxhighlight lang="lua">
 +
--Pattern: ^\#(\d+)\s(.+)$
 +
 
 +
local cmd = matches[3]
 +
for i=1, tonumber(matches[2]) do 
 +
  local tempCMD = string.gsub(cmd, "%%i", i)
 +
  expandAlias(tempCMD)
 +
end
 +
 
 +
-- We have to store the initial matches table in a variable because each loop might change the current matches table.
 +
 
 +
</syntaxhighlight>
 +
 
 +
'''#Example #9 - controlling many characters at once'''
 +
Check out [https://forums.mudlet.org/viewtopic.php?f=6&t=23023 this premade package] that helps you with this.
  
==From zMUD==
+
=From zMUD=
 +
Pretty similar to migrating [[#From CMUD]] - see above.

Latest revision as of 16:48, 18 January 2024

From Nexus

Note Note: The Nexus information seems a bit out of date. Please feel free to add or update with more current instructions.

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)
Note:
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

Calling functions
Mudlet Nexus
send("hi")
echo("Hello to me!")

#send hi
#echo Hello to me!

Note:

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

Setting variables
Mudlet Nexus
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))

#set number 1234
#echo My number is: $number
#echo the $number is in the middle of my text

Wildcards To use the wildcard variable in Nexus, you’d use $1 for the first match, $2 for the second and so on. In Mudlet, the matches[] table contains the matches - and it starts placing the matches from 2. So the Nexus $1 would be matches[2], $2 would be matches[3].
Mudlet Nexus
(\w+) kicks you\.
badguy = matches[2]
echo(badguy .. " kicked me!")

{w} kicks you.
#set badguy $1
#echo $badguy kicked me!

alias pattern: ^t (.*)$
alias script: target = matches[2]

alias name: t
alias script: #set target $1

Note:

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.

#wait In Nexus, a #wait will freeze the script while it’s executing - such that commands after it are delayed. In Mudlet, we use tempTimer which that works a bit differently - it doesn’t freeze the script, but instead makes it so commands a tempTimer is asked to do will get done in the future. So the difference is that a tempTimer doesn’t freeze the commands following it at all, everything gets done at once as usual. Just things a tempTimer was asked to do get done in the future.
Mudlet Nexus
send("hello")
tempTimer(1, [[send("hi")]])
tempTimer(1.5, [[send("bye")]])

#send hello
#wait 1000
#send hi
#wait 500
#send bye

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> then <script> else <script> end

#if <condition> { <script> } else { <script> } #if <condition> { <script> } { <script> }

if <condition> then <script> elseif <condition> then <script> end

#if <condition> { <script> } elsif <condition> { <script> }

if <condition> then <script> elseif <condition> then <script> else <script> end

#if <condition> { <script> } elsif <condition> { <script> } else { <script> }


Here is the sample side-by-side comparison of how you’d use it:

Mudlet Nexus
-- If foo is true, echo that fact.
  if foo then echo ("Foo is true!") end -- If foo is true, echo that fact.

-- A slight modification of the above that illustrates an 'else' clause.
-- Note that the 'then' is always necessary to avoid confusion.
  if foo then echo ("Foo is true!") else echo ("Foo is false!") end

-- Illustration of putting more than one statement in a block (also
-- spans lines here). Note the if doesn't end until the last 'end' is
-- encountered.
-- We also add a \n at the end of multiple echos so each one is on it's own line.
  if foo then
    echo ("Foo is true!\n")
    echo ("Isn't it grand?\n")
    echo ("These commands are all on separate lines too!\n")
  end

-- This shows how ifs continue (on 'logical' lines) even though the
-- blocks in its constituent clauses may have multiple lines. The
-- following lines are all _one_ single if statement.
  if foo > 50 then
    echo ("Foo is big!\nYes it is.")
  elseif foo > 10 then
    echo ("Foo is pretty big...\n")
    echo ("I've seen bigger.")
  else
    echo ("Foo is actually kind of small.")
  end

-- Ifs can be nested too.
  if foo then
    if bar then
      echo ("Both foo and bar are true.")
    else
      echo ("Foo's true, but bar isn't.")
    end
  end


// If $foo is true, echo that fact.

 #if $foo #echo Foo is true!     // If $foo is true, echo that fact.


// A slight modification of the above that illustrates an 'else' clause.
// The second form shows that the word 'else' is actually optional too.
// (The two lines are functionally the same.)

 #if $foo { #echo Foo is true! } else { #echo Foo is false! }
 #if $foo { #echo Foo is true! } { #echo Foo is false! }


// Illustration of putting more than one statement in a block (also
// spans lines here). Note the if doesn't end until the last '}' is
// encountered.

 #if $foo {
   #echo Foo is true!
   #echo Isn't it grand?
   #echo These commands are all on separate lines too!
 }


// This shows how ifs continue (on 'logical' lines) even though the
// blocks in its constituent clauses may have multiple lines. The
// following lines are all _one_ single if statement.

 #if $foo > 50 {
   #echo Foo is big!
   #echo Yes it is.
 } elsif $foo > 10 {
   #echo Foo is pretty big...
   #echo I've seen bigger.
 } else {
   #echo Foo is actually kind of small.
 }

// Ifs can be nested too.

 #if $foo {
   #if $bar {
     #echo Both foo and bar are true.
   } else {
     #echo Foo's true, but bar isn't.
   }
 }

Mudlet equivalents of Nexus functions

Now that we got the ifs covered, lets go over the Mudlet equivalents of other Nexus functions. Note that this is a direct Nexus→Mudlet comparison; certain functions in Mudlet have much more capability.

Mudlet Nexus
<variable name> = "<text value>" #set <variable name> <text value>
<variable name> = <expression> #set <variable name> = <expression>
<variable name> = nil #unset <variable name>
<variable> = <variablename> <+ - / *> <number or variable> #add <variablename> <expression>
echo "text\n" or echo("text\n") #echo <text>
echo "text" or echo("text") #echo_ <text>
enableAlias("<group name>")/enableTrigger()/enableKey()/enableTimer() #groupon <group name>
disableAlias("<group name>")disableTrigger()disableKey()disableTimer() #groupoff <group name>
selectString (line, 1) bg("<color>") resetFormat() #highlight <color>
deleteLine() #gag
openUrl("<url>") #openurl <url>
send("<stuff>") #send <text>
sendAll("hi", "hello", "bye") #send_ hi #send_ hello #send bye
tempTimer(<time in s>, [[ <lua code to do once time is up> ]]) #wait <milliseconds>

How to call aliases in Mudlet

The typical workflow in Nexus is that you’d define the aliases for yourself to use, and also use aliases for system-related things (things like checking if you’d need to eat a herb, etc).

While the first use is good, the second isn’t - because the user can also run this alias at an inopportune time, because if you want to call an alias it has to match all alises again, and so on.

Now, while in Mudlet you can call another alias with the expandAlias() function, this is strongly discouraged. What you do instead if create a function (for example, send() and echo() are functions) that you can then call from your alias or trigger. This has many advantages - it’s faster, you can easily give your function values, and your function can return you values, too.

To make a function, you go to the Scripts section, create a new script, and write in your function:

  function <name> ()
    <stuff it does>
  end

For example, if we want to make a function that does two things for us at once, we’d do this:

  function eat_bloodroot()
    send ("outr bloodroot")
    send ("eat bloodroot")
  end

Then just do this in our alias or trigger to outr and eat bloodroot:

  eat_bloodroot()

As mentioned, you can also give things to functions - in this case lets expand the function to eat any herb for us we tell it:

  function eat (what)
    send ("outr " .. what)
    send ("eat " .. what)
  end
  [...]
  eat ("bloodroot")
  eat ("kelp")
  eat ("ginseng")

Lastly, functions can also give you data back. One useful example for this is to break down tasks into functions, which will help your code readability:

  function can_i_stand()
    if not paralyzed and not prone and not stunned then
      return true
    else
      return false
  end
  [...]
  if can_i_stand() and have_balance and have_equilibrium then
    send ("stand")
  end

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 as 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
  • Send() in MUSHclient is called send() with a lower S in Mudlet - in Lua, capitalization matters! To send a command without echoing it on the screen, use:
send("my text", false)
  • While MUSHclient uses AnsiNote to write colorful text, Mudlet offers different ways as well: cecho() works with the name of a color. You can find lots of predefined colors with showColors(). You can also style foreground and background seperately with fg() and bg(). To keep your original ANSI colors, use ansi2decho(). If you need more colors, decho() will take rgb numbers, hecho() uses hex codes.
  • Mudlet does not offer 'GetConnectDuration()' but you could create a script to connect to the connection event (and maybe sysDisconnectionEvent) and in that function start a stopwatch to keep count of how long you've been connected for. See Manual:Event Engine on how to use events in Mudlet.
  • Mudlet does not have lpeg built-in but you can include the lpeg library installed on your system in your lua code. On Windows, you can choose to put the lpeg.dll file into Mudlet's install folder. On macOS that is not possible due to restrictions placed by Apple.
  • If you used OnPluginPartialLine to match "partial lines" such as prompts, please note that any type of Mudlet triggers should work with such lines so you can just use them for your purpose. For prompts specifically, try tempPromptTrigger.
  • If you used OnPluginTick, you can use a GUI timer in Mudlet for essentially the same functionality.
  • If you used OnPluginCommandEntered, you can use a "catch all" alias (with a pattern like "^.+") to send all user commands to your script.
  • If you have an existing database you'd like to use and don't want to put it into the profile folder, you can use the standard luaSQL interface to load and use it. Some basic examples can be found at https://keplerproject.github.io/luasql/examples.html
  • Line numbers in Mudlet are absolute - lines will not get renumbered when they start getting deleted from the buffer.

Converting MUSHclient triggers into Mudlet triggers

The following scripts by Discord user Buck allow you to paste a MUSHclient trigger and automatically have a corresponding Mudlet trigger created.

First, create a new script with this:

TRIGGER_GROUP_NAME = "mushtriggers"
MUSHTRIGGER_PREFIX = "mt_"

function getAvailableMushTriggerID()
  local n=1

  while exists( MUSHTRIGGER_PREFIX..tostring( n), 'trigger')>0 do
    n=n+1
  end

  return MUSHTRIGGER_PREFIX..tostring( n)
end

function addMushTrigger( pattern, actions)
  pattern = string.gsub( pattern, '%.', '\\.')
  pattern = string.gsub( pattern, '*', '(.+)')
  actions_regex = string.gsub( actions, '%%(%d)', function(x) return ']]..matches['..tostring(x+1)..']..[[' end)

  local id = getAvailableMushTriggerID()

  createTriggerGroup( TRIGGER_GROUP_NAME)
  permRegexTrigger(
    id,
    TRIGGER_GROUP_NAME,
    {pattern},
    'for _, cmd in ipairs( splitCommands( [['..actions_regex..']])) do expandAlias( cmd) end')
end

Also create an alias with this:

-- ^/trigger '([^']+)' (.+)$
local pattern = matches[2]
local actions = matches[3]

addMushTrigger(pattern, actions)

cecho("<green>New trigger added")

Now you can transfer your MUSH triggers like so:

/trigger 'A wild * enters the room' hit %1 

/trigger '%d/%dhp %d/%dmn' /checkhealth %1

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:

Pattern:
^A (.*) shard appears and clatters to the ground\.$

Code:
#IF (@autogold) {
#temp {You have recovered balance on all limbs.} 
{get shard}
}

Mudlet Example:

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

Example #2 - Doing Math: Cmud:

Pattern:
^You put (\d+) gold sovereigns in (.*)\.$

Code:
#ADD goldcounter %1

Mudlet:

Pattern: 
^You put (\d+) gold sovereigns in (.*)\.$

Code:
goldcounter = goldcounter + tonumber(matches[2])

Example #3 - Replacing Text Cmud

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*)}

Mudlet

Pattern:
^You raze (\w+) magical shield with (.*)\.$

Code:
deleteLine()
cecho("<yellow:cyan>You RAZED " .. matches[2] .. " shield")

Example #4 - Enable/Disable Classes

Cmud:

#T+ ClassFolderName

Mudlet:

enableAlias("ClassFolderName")

-- Note: Alias can be an alias, trigger (enableTrigger), timer (enableTimer), key (enableKey), etc. 
-- You can disable entire classes or just single triggers.

Example 5 - Multi-action Commands Let's say we create an alias called silly

Cmud:

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

Mudlet:

Pattern: 
sillyAction

Code:
sendAll("look","ct Hello City","pt Hello Party", "laugh")

-- 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:

expandAlias("sillyAction")

Example 6 - Using if statements with and, or and nil.

Cmud Code:

#IF (@myclass="knight" & !(@pets))
{
say cool
}

Mudlet Code:

if myclass == "knight" and not pets then
  send("say cool")
end

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:

Pattern: ^kk ?(\w+)?$
#VAR target Das
if (@target) {
kick @target
}
if (%1) {
kick %1
}

Mudlet:

Pattern: 
^kk ?(\w+)?$

Code:
target = "Das"
send("kick "..(matches[2] or target))

Example #7 - Two Pattern Examples

^rz(?:(.*)|)$  
-- This would let you do rzDas to raze Das for example.

Versus:

^rz ?(\w+)?$ 
-- This would require you to do rz Das with a space between rz and Das.

Example #8 - Repeat Commands a number of times with %i functionality, i.e., #12 kill bug %i will send "kill bug 1", "kill bug 2", "kill bug 3"...etc

--Pattern: ^\#(\d+)\s(.+)$

local cmd = matches[3]
for i=1, tonumber(matches[2]) do  
  local tempCMD = string.gsub(cmd, "%%i", i)
  expandAlias(tempCMD)
end

-- We have to store the initial matches table in a variable because each loop might change the current matches table.

#Example #9 - controlling many characters at once Check out this premade package that helps you with this.

From zMUD

Pretty similar to migrating #From CMUD - see above.