Difference between revisions of "Manual:Lua API"
Jump to navigation
Jump to search
(7 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | =Lua API= | + | <languages/> |
− | + | <translate> | |
− | + | =Lua API= <!--T:1--> | |
+ | <br/> | ||
Mudlet defines several global Lua variables that are accessible from anywhere. | Mudlet defines several global Lua variables that are accessible from anywhere. | ||
− | {| border="2" | + | <!--T:2--> |
− | ! | + | {| border="2" cellpadding="4" |
+ | !colspan="6" | Built-in Lua Variables | ||
|- | |- | ||
− | !Variable Name | + | !colspan="2" | Variable Name |
− | !Description | + | !colspan="4" | Description |
|- | |- | ||
− | | | + | |colspan="2" | command |
− | |This variable holds the current user command. This is typically used in alias scripts. | + | |colspan="4" | This variable holds the current user command. This is typically used in alias scripts. |
|- | |- | ||
− | |line | + | |colspan="2" | line |
− | |This variable holds the content of the current line as being processed by the trigger engine. The engine runs all triggers on each line as it arrives from the MUD. | + | |colspan="4" | This variable holds the content of the current line as being processed by the trigger engine. The engine runs all triggers on each line as it arrives from the MUD. |
|- | |- | ||
− | |matches[n] | + | |colspan="2" | matches[n] |
− | |This Lua table is being used by Mudlet in the context of triggers that use Perl regular expressions. matches[1] holds the entire match, matches[2] holds the first capture group, matches[n] holds the nth-1 capture group. | + | |colspan="4" | This Lua table is being used by Mudlet in the context of aliases and triggers that use Perl regular expressions. |
− | + | matches[1] holds the entire match, matches[2] holds the first capture group, matches[n] holds the nth-1 capture group. | |
− | If the trigger uses the Perl style /g switch to evaluate all possible matches of the given regex within the current line, matches[n+1] will hold the second entire match, matches[n+2] the first capture group of the second match and matches[n+m] the m-th capture group of the second match. | + | If the trigger uses the Perl style /g switch to evaluate all possible matches of the given regex within the current line, matches[n+1] will hold the second entire match, matches[n+2] the first capture group of the second match and matches[n+m] |
+ | the m-th capture group of the second match. | ||
|- | |- | ||
|colspan="2" | multimatches[n][m] | |colspan="2" | multimatches[n][m] | ||
− | |This table is being used by Mudlet in the context of multiline triggers that use Perl regular expression. It holds the table matches[n] as described above for each Perl regular expression based condition of the multiline trigger. multimatches[5][4] may hold the 3rd capture group of the 5th regex in the multiline trigger. This way you can examine and process all relevant data within a single script. Have a look at this example. | + | |colspan="4" | This table is being used by Mudlet in the context of multiline triggers that use Perl regular expression. It holds the table matches[n] as described above for each Perl regular expression based condition of the multiline trigger. multimatches[5][4] may hold the 3rd capture group of the 5th regex in the multiline trigger. This way you can examine and process all relevant data within a single script. Have a look at this example. |
|} | |} | ||
− | |||
− | |||
− | + | ==Useful Lua resources on the Web== <!--T:3--> | |
− | + | <!--T:4--> | |
+ | *[http://thomaslauer.com/download/luarefv51single.pdf Lua reference card] | ||
+ | *[http://lua-users.org/wiki/TutorialDirectory Lua Tutorial Directory] | ||
+ | *[http://wowprogramming.com/utils/weblua A Lua console in your browser, very useful when doing tutorials] | ||
+ | </translate> |
Latest revision as of 07:43, 16 July 2024
Lua API
Mudlet defines several global Lua variables that are accessible from anywhere.
Built-in Lua Variables | |||||
---|---|---|---|---|---|
Variable Name | Description | ||||
command | This variable holds the current user command. This is typically used in alias scripts. | ||||
line | This variable holds the content of the current line as being processed by the trigger engine. The engine runs all triggers on each line as it arrives from the MUD. | ||||
matches[n] | This Lua table is being used by Mudlet in the context of aliases and triggers that use Perl regular expressions.
matches[1] holds the entire match, matches[2] holds the first capture group, matches[n] holds the nth-1 capture group. If the trigger uses the Perl style /g switch to evaluate all possible matches of the given regex within the current line, matches[n+1] will hold the second entire match, matches[n+2] the first capture group of the second match and matches[n+m] the m-th capture group of the second match. | ||||
multimatches[n][m] | This table is being used by Mudlet in the context of multiline triggers that use Perl regular expression. It holds the table matches[n] as described above for each Perl regular expression based condition of the multiline trigger. multimatches[5][4] may hold the 3rd capture group of the 5th regex in the multiline trigger. This way you can examine and process all relevant data within a single script. Have a look at this example. |