Difference between revisions of "Translations:Manual:Lua Functions/3/en"

From Mudlet
Jump to navigation Jump to search
(Importing a new version from external source)
 
(Importing a new version from external source)
 
Line 31: Line 31:
 
|colspan="2" | <code>mudlet.supports</code>
 
|colspan="2" | <code>mudlet.supports</code>
 
|colspan="4" | Lists special functionality that the users Mudlet supports - right now, just <code>mudlet.supports.coroutines</code> is listed. Use <code>mudlet.supports</code> to conditionally enable functionality as it's available on the users Mudlet.
 
|colspan="4" | Lists special functionality that the users Mudlet supports - right now, just <code>mudlet.supports.coroutines</code> is listed. Use <code>mudlet.supports</code> to conditionally enable functionality as it's available on the users Mudlet.
 +
|-
 +
|colspan="2" | <code>color_table</code>
 +
|colspan="4" | Color definitions used by Geyser, cecho, and many other functions - see [[Special:MyLanguage/Manual:UI_Functions#showColors|showColors()]]. The profile's color preferences are also accessible under the <code>ansi_</code> keys.
 
|}
 
|}
 
   
 
   
 
There are other variables that hold MUD-protocol data that are global as well - see [[Special:MyLanguage/Manual:Technical_Manual#Supported_Protocols|Supported Protocols]].
 
There are other variables that hold MUD-protocol data that are global as well - see [[Special:MyLanguage/Manual:Technical_Manual#Supported_Protocols|Supported Protocols]].

Latest revision as of 23:30, 14 June 2020

Information about message (contribute)
This message has no documentation. If you know where or how this message is used, you can help other translators by adding documentation to this message.
Message definition (Manual:Lua Functions)
{| border="2" cellpadding="4"
!colspan="6" | Built-in Lua Variables
|-
!colspan="2" | Variable Name
!colspan="4" | Description
|-
|colspan="2" | <code>command</code>
|colspan="4" | This variable holds the current user command, i.e. unchanged by any aliases or triggers. This is typically used in alias scripts.
|-
|colspan="2" | <code>line</code>
|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.
|-
|colspan="2" | <code>matches[n]</code>
|colspan="4" | 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.
If the Perl trigger indicated 'match all' (same effect as the Perl /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" | <code>multimatches[n][m]</code>
|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.
|-
|colspan="2" | <code>mudlet.translations</code>
|colspan="4" | Contains translations of some common texts (right now, exit directions only) that are helpful to you in Lua scripting, as well as the current language selected for the user interface.  - See [[Special:MyLanguage/Manual:Miscellaneous_Functions#translateTable|translateTable()]]
|-
|colspan="2" | <code>mudlet.key</code>
|colspan="4" | Makes your life easier when creating new keybindings via Lua by translating the key name into the number needed - see [[Special:MyLanguage/Manual:Mudlet_Object_Functions#tempKey|tempKey()]].
|-
|colspan="2" | <code>mudlet.keymodifier</code>
|colspan="4" | Same as <code>mudlet.key</code>, but for keyboard modifiers - Ctrl, Alt, etc.
|-
|colspan="2" | <code>mudlet.supports</code>
|colspan="4" | Lists special functionality that the users Mudlet supports - right now, just <code>mudlet.supports.coroutines</code> is listed. Use <code>mudlet.supports</code> to conditionally enable functionality as it's available on the users Mudlet.
|-
|colspan="2" | <code>color_table</code>
|colspan="4" | Color definitions used by Geyser, cecho, and many other functions - see [[Special:MyLanguage/Manual:UI_Functions#showColors|showColors()]]. The profile's color preferences are also accessible under the <code>ansi_</code> keys.
|}
 
There are other variables that hold MUD-protocol data that are global as well - see [[Special:MyLanguage/Manual:Technical_Manual#Supported_Protocols|Supported Protocols]].
Built-in Lua Variables
Variable Name Description
command This variable holds the current user command, i.e. unchanged by any aliases or triggers. 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 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 Perl trigger indicated 'match all' (same effect as the Perl /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.
mudlet.translations Contains translations of some common texts (right now, exit directions only) that are helpful to you in Lua scripting, as well as the current language selected for the user interface. - See translateTable()
mudlet.key Makes your life easier when creating new keybindings via Lua by translating the key name into the number needed - see tempKey().
mudlet.keymodifier Same as mudlet.key, but for keyboard modifiers - Ctrl, Alt, etc.
mudlet.supports Lists special functionality that the users Mudlet supports - right now, just mudlet.supports.coroutines is listed. Use mudlet.supports to conditionally enable functionality as it's available on the users Mudlet.
color_table Color definitions used by Geyser, cecho, and many other functions - see showColors(). The profile's color preferences are also accessible under the ansi_ keys.

There are other variables that hold MUD-protocol data that are global as well - see Supported Protocols.