Area 51
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in Lua Functions and its sub-sites.
Please use the Area_51/Template to add new entries in the sections below.
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the '#' character in the link identifier on the left side of the '|' divider between the identifier and the display text. e.g.
- [[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]
rather than:
- [[#getCustomLines|getCustomLines()]]
which would refer to a link within the current (in this case Area 51) section. Note that this ought to be removed once the article is moved to the main wiki area!
The following headings reflect those present in the main Wiki area of the Lua API functions. It is suggested that new entries are added so as to maintain a sorted alphabetical order under the appropriate heading.
Basic Essential Functions
- These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.
Database Functions
- A collection of functions for helping deal with the database.
Date/Time Functions
- A collection of functions for handling date & time.
File System Functions
- A collection of functions for interacting with the file system.
Mapper Functions
- A collection of functions that manipulate the mapper and its related features.
mapSymbolFontInfo, PR #4038 closed
- mapSymbolFontInfo()
- See also: setupMapSymbolFont()
Note: pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
- returns
- either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:
- fontName - a string of the family name of the font specified
- onlyUseThisFont - a boolean indicating whether glyphs from just the fontName font are to be used or if there is not a glyph for the required grapheme (character) then a glyph from the most suitable different font will be substituted instead. Should this be true and the specified font does not have the required glyph then the replacement character (typically something like �) could be used instead. Note that this may not affect the use of Color Emoji glyphs that are automatically used in some OSes but that behavior does vary across the range of operating systems that Mudlet can be run on.
- scalingFactor - a floating point number between 0.50 and 2.00 which modifies the size of the symbols somewhat though the extremes are likely to be unsatisfactory because some of the particular symbols may be too small (and be less visible at smaller zoom levels) or too large (and be clipped by the edges of the room rectangle or circle).
- or nil and an error message on failure.
- As the symbol font details are stored in the (binary) map file rather than the profile then this function will not work until a map is loaded (or initialized, by activating a map window).
moveMapLabel, PR #6014 open
- moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
Re-positions a map label within an area in the 2D mapper, in a similar manner as the moveRoom() function does for rooms and their custom exit lines. When moving a label to given coordinates this is the position that the top-left corner of the label will be positioned at; since the space allocated to a particular room on the map is ± 0.5 around the integer value of its x and y coordinates this means for a label which has a size of 1.0 x 1,0 (w x h) to position it centrally in the space for a single room at the coordinates (x, y, z) it should be positioned at (x - 0.5, y + 0.5, z).
- See also: getMapLabels(), getMapLabel().
Note: pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014
- Parameters
- areaID/Name:
- Area ID as number or AreaName as string containing the map label.
- labelID/Text:
- Label ID as number (which will be 0 or greater) or the LabelText on a text label. All labels will have a unique ID number but there may be more than one text labels with a non-empty text string; only the first matching one will be moved by this function and image labels also have no text and will match the empty string. with mo or AreaName as string containing the map label.
- coordX/deltaX:
- A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the X-axis.
- coordY/deltaY:
- A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Y-axis.
- coordZ/deltaZ:
- (Optional) A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Z-axis, if omitted the label is not moved in the z-axis at all.
- absoluteNotRelativeMove:
- (Optional) a boolean value (defaults to false if omitted) as to whether to move the label to the absolute coordinates (true) or to move it the relative amount from its current location (false).
- Returns
- true on success or nil and an error message on failure, if successful it will also refresh the map display to show the result.
- Example
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
moveMapLabel(0, 2, 3.0, 4.0)
-- move the first label in the area with the ID number of 2, one space to the west, note the final boolean argument is unneeded
moveMapLabel(0, 2, -1.0, 0.0, false)
-- move the second label in the area with the ID number of 2, three and a half spaces to the west, and two south **of the center of the current level it is on in the map**:
moveRoom(1, 2, -3.5, -2.0, true)
-- move the second label in the area with the ID number of 2, up three levels
moveRoom(1, 2, 0.0, 0.0, 3.0)
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)
-- move the (top-left corner of the first) label with the text "Home" in the area with ID number 5 to the **center of the whole map**, note the last two arguments are required in this case:
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas
moveRoom, PR #6010 open
- moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
Re-positions a room within an area, in the same manner as the "move to" context menu item for one or more rooms in the 2D mapper. Like that method this will also shift the entirety of any custom exit lines defined for the room concerned. This contrasts with the behavior of the setRoomCoordinates() which only moves the starting point of such custom exit lines so that they still emerge from the room to which they belong but otherwise remain pointing to the original place.
- See also: setRoomCoordinates()
Note: pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010
- Parameters
- roomID:
- Room ID number to move.
- coordX/deltaX:
- The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.
- coordY/deltaY:
- The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.
- coordZ/deltaZ:
- (Optional) the absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Z-axis, if omitted the room is not moved in the z-axis at all.
- absoluteNotRelativeMove:
- (Optional) a boolean value (defaults to false if omitted) as to whether to move the room to the absolute coordinates (true) or the relative amount from its current location (false).
- Returns
- true on success or nil and an error message on failure, if successful it will also refresh the map display to show the result.
- Example
-- move the first room one space to the east and two spaces to the north
moveRoom(1, 1, 2)
-- move the first room one space to the west, note the final boolean argument is unneeded
moveRoom(1, -1, 0, false)
-- move the first room three spaces to the west, and two south **of the center of the current level it is on in the map**:
moveRoom(1, -3, -2, true)
-- move the second room up three levels
moveRoom(2, 0, 0, 3)
-- move the second room one space to the west, note the last two arguments are unneeded
moveRoom(2, -1, 0, 0, false)
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:
moveRoom(2, 0, 0, 0, true)
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers
setupMapSymbolFont, PR #4038 closed
- setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
- configures the font used for symbols in the (2D) map.
- See also: mapSymbolFontInfo()
Note: pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
- Parameters
- fontName one of:
- - a string that is the family name of the font to use;
- - the empty string "" to reset to the default {which is "Bitstream Vera Sans Mono"};
- - a Lua nil as a placeholder to not change this parameter but still allow a following one to be modified.
- onlyUseThisFont (optional) one of:
- - a Lua boolean true to require Mudlet to use graphemes (character) only from the selected font. Should a requested grapheme not be included in the selected font then the font replacement character (�) might be used instead; note that under some circumstances it is possible that the OS (or Mudlet) provided color Emoji Font may still be used but that cannot be guaranteed across all OS platforms that Mudlet might be run on;
- - a Lua boolean false to allow Mudlet to get a different glyph for a particular grapheme from the most suitable other font found in the system should there not be a glyph for it in the requested font. This is the default unless previously changed by this function or by the corresponding checkbox in the Profile Preferences dialogue for the profile concerned;
- - a Lua nil as a placeholder to not change this parameter but still allow the following one to be modified.
- scalingFactor (optional): a floating point value in the range 0.5 to 2.0 (default 1.0) that can be used to tweak the rectangular space that each different room symbol is scaled to fit inside; this might be useful should the range of characters used to make the room symbols be consistently under- or over-sized.
- Returns
- true on success
- nil and an error message on failure. As the symbol font details are stored in the (binary) map file rather than the profile then this function will not work until a map is loaded (or initialised, by activating a map window).
Miscellaneous Functions
- Miscellaneous functions.
createVideoPlayer, PR #6439
- createVideoPlayer([name of userwindow], x, y, width, height)
- Creates a miniconsole window for the video player to render in, the with the given dimensions. One can only create one video player at a time (currently), and it is not currently possible to have a label on or under the video player - otherwise, clicks won't register.
Note: A video player may also be created through use of the Mud Client Media Protocol, the playVideoFile() API command, or adding a Geyser.VideoPlayer object to ones user interface such as the example below.
Note: The Main Toolbar will show a Video button to hide/show the video player, which is located in a userwindow generated through createVideoPlayer, embedded in a user interface, or a dock-able widget (that can be floated free to anywhere on the Desktop, it can be resized and does not have to even reside on the same monitor should there be multiple screens in your system). Further clicks on the Video button will toggle between showing and hiding the map whether it was created using the createVideo function or as a dock-able widget.
See also: loadSoundFile(), loadMusicFile(), loadVideoFile(), playSoundFile(), playMusicFile(), playVideoFile(), stopSounds(), stopMusic(), stopVideos(), purgeMediaCache(), Mud Client Media Protocol
- Example
-- Create a 300x300 video player in the top-left corner of Mudlet
createVideoPlayer(0,0,300,300)
-- Alternative examples using Geyser.VideoPlayer
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({
name = "GUI.VideoPlayer",
x = "70%", y = 0, -- edit here if you want to move it
width = "30%", height = "50%"
}, GUI.Right)
loadVideoFile, PR #6439
- loadVideoFile(settings table) or loadVideoFile(name, [url])
- Loads video files from the Internet or the local file system to the "media" folder of the profile for later use with playVideoFile() and stopVideos(). Although files could be loaded or streamed directly at playing time from playVideoFile(), loadVideoFile() provides the advantage of loading files in advance.
Note: Video files consume drive space on your device. Consider using the streaming feature of playVideoFile() for large files.
Required | Key | Value | Purpose |
---|---|---|---|
Yes | name | <file name> |
|
Maybe | url | <url> |
|
See also: loadSoundFile(), loadMusicFile(), playSoundFile(), playMusicFile(), playVideoFile(), stopSounds(), stopMusic(), stopVideos(), createVideoPlayer(), purgeMediaCache(), Mud Client Media Protocol
- Example
---- Table Parameter Syntax ----
-- Download from the Internet
loadVideoFile({
name = "TextInMotion-VideoSample-1080p.mp4"
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"
})
-- OR download from the profile
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})
-- OR download from the local file system
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----
-- Download from the Internet
loadVideoFile(
"TextInMotion-VideoSample-1080p.mp4"
, "https://d2qguwbxlx1sbt.cloudfront.net/"
)
-- OR download from the profile
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")
-- OR download from the local file system
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")
playVideoFile, PR #6439
- playVideoFile(settings table)
- Plays video files from the Internet or the local file system for later use with stopMusic(). Video files may be downloaded to the device and played, or streamed from the Internet when the value of the
stream
parameter istrue
.
Required | Key | Value | Default | Purpose |
---|---|---|---|---|
Yes | name | <file name> |
| |
No | volume | 1 to 100 | 50 |
|
No | fadein | <msec> |
| |
No | fadeout | <msec> |
| |
No | start | <msec> | 0 |
|
No | loops | -1, or >= 1 | 1 |
|
No | key | <key> |
| |
No | tag | <tag> |
| |
No | continue | true or false | true |
|
Maybe | url | <url> |
| |
Maybe | stream | true or false | false |
|
See also: loadSoundFile(), loadMusicFile(), loadVideoFile(), playSoundFile(), playMusicFile(), stopSounds(), stopMusic(), stopVideos(), createVideoPlayer(), purgeMediaCache(), Mud Client Media Protocol
- Example
---- Table Parameter Syntax ----
-- Stream a video file from the Internet and play it.
playVideoFile({
name = "TextInMotion-VideoSample-1080p.mp4"
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"
, stream = true
})
-- Play a video file from the Internet, storing it in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media) so you don't need to download it over and over. You could add ", stream = false" below, but that is the default and is not needed.
playVideoFile({
name = "TextInMotion-VideoSample-1080p.mp4"
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"
})
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playVideoFile({
name = "TextInMotion-VideoSample-1080p.mp4"
})
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile({
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"
, volume = 75
})
-- OR copy once from the local file system, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile({
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"
, volume = 75
})
-- OR download once from the Internet, and play a video stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "text" for stopping this unique video later
---- [tag] reference of "ambience" to stop any video later with the same tag
---- [continue] playing this video if another request for the same video comes in (false restarts it)
---- [url] resource location where the file may be accessed on the Internet
---- [stream] download once from the Internet if the video does not exist in the profile's media directory when false (true streams from the Internet and will not download to the device)
playVideoFile({
name = "TextInMotion-VideoSample-1080p.mp4"
, volume = nil -- nil lines are optional, no need to use
, fadein = 10000
, fadeout = 15000
, start = 5000
, loops = nil -- nil lines are optional, no need to use
, key = "text"
, tag = "ambience"
, continue = true
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"
, stream = false
})
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----
-- Stream a video file from the Internet and play it.
playVideoFile(
"TextInMotion-VideoSample-1080p.mp4"
, nil -- volume
, nil -- fadein
, nil -- fadeout
, nil -- start
, nil -- loops
, nil -- key
, nil -- tag
, true -- continue
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
, false -- stream
)
-- Play a video file from the Internet, storing it in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media) so you don't need to download it over and over.
playVideoFile(
"TextInMotion-VideoSample-1080p.mp4"
, nil -- volume
, nil -- fadein
, nil -- fadeout
, nil -- start
, nil -- loops
, nil -- key
, nil -- tag
, true -- continue
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
, false -- stream
)
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playVideoFile(
"TextInMotion-VideoSample-1080p.mp4" -- name
)
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile(
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name
, 75 -- volume
)
-- OR copy once from the local file system, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile(
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name
, 75 -- volume
)
-- OR download once from the Internet, and play a video stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "text" for stopping this unique video later
---- [tag] reference of "ambience" to stop any video later with the same tag
---- [continue] playing this video if another request for the same video comes in (false restarts it)
---- [url] resource location where the file may be accessed on the Internet
---- [stream] download once from the Internet if the video does not exist in the profile's media directory when false (true streams from the Internet and will not download to the device)
playVideoFile(
"TextInMotion-VideoSample-1080p.mp4" -- name
, nil -- volume
, 10000 -- fadein
, 15000 -- fadeout
, 5000 -- start
, nil -- loops
, "text" -- key
, "ambience" -- tag
, true -- continue
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
, false -- stream
)
stopVideos, PR #6439
- stopVideos(settings table)
- Stop all videos (no filter), or videos that meet a combination of filters (name, key, and tag) intended to be paired with playVideoFile().
Required | Key | Value | Purpose |
---|---|---|---|
No | name | <file name> |
|
No | key | <key> |
|
No | tag | <tag> |
|
See also: loadSoundFile(), loadMusicFile(), loadVideoFile(), playSoundFile(), playMusicFile(), playVideoFile(), stopSounds(), stopMusic(), createVideoPlayer(), purgeMediaCache(), Mud Client Media Protocol
- Example
---- Table Parameter Syntax ----
-- Stop all playing video files for this profile associated with the API
stopVideos()
-- Stop playing the text mp4 by name
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})
-- Stop playing the unique sound identified as "text"
stopVideos({
name = nil -- nil lines are optional, no need to use
, key = "text" -- key
, tag = nil -- nil lines are optional, no need to use
})
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----
-- Stop all playing video files for this profile associated with the API
stopVideos()
-- Stop playing the text mp4 by name
stopVideos("TextInMotion-VideoSample-1080p.mp4")
-- Stop playing the unique sound identified as "text"
stopVideos(
nil -- name
, "text" -- key
, nil -- tag
)
setConfig
- setConfig(option, value)
- Sets a Mudlet option to a certain value. This comes in handy for scripts that want to customise Mudlet settings to their preferences - for example, setting up mapper room and exit size to one that works for a certain map, or enabling MSDP for a certain game. For transparency reasons, the Debug window (when open) will show which options were modified by scripts.
- To set many options at once, pass in a table of options. More options will be added over time / per request.
- Parameters
- option:
- Particular option to change - see list below for available ones.
- value:
- Value to set - can be a boolean, number, or text depending on the option.
Option | Description | Available in Mudlet |
---|---|---|
enableGMCP | Enable GMCP (on by default. Reconnect after changing) | 4.16 |
enableMSDP | Enable MSDP (off by default. Reconnect after changing) | 4.16 |
enableMSSP | Enable MSSP (on by default. Reconnect after changing) | 4.16 |
enableMSP | Enable MSP (on by default. Reconnect after changing) | 4.16 |
Option | Description | Available in Mudlet |
---|---|---|
inputLineStrictUnixEndings | Workaround option to use strict UNIX line endings for sending commands | 4.16 |
Option | Description | Available in Mudlet |
---|---|---|
fixUnnecessaryLinebreaks | Remove extra linebreaks from output (mostly for IRE servers) | 4.16 |
Option | Description | Available in Mudlet |
---|---|---|
mapRoomSize | Size of rooms on map (a good value is 5) | 4.16 |
mapExitSize | Size of exits on map (a good value is 10) | 4.16 |
mapRoundRooms | Draw rooms round or square | 4.16 |
showRoomIdsOnMap | Show room IDs on all rooms (if zoom permits) | 4.16 |
showMapInfo | Map overlay text ('Full' or 'Short', can have both at once) | 4.16 |
hideMapInfo | Map overlay text ('Full' or 'Short', hide both to hide info altogether) | 4.16 |
show3dMapView | Show map as 3D | 4.16 |
mapperPanelVisible | Map controls at the bottom | 4.16 |
mapShowRoomBorders | Draw a thin border for every room | 4.16 |
Option | Description | Available in Mudlet |
---|---|---|
specialForceCompressionOff | Workaround option to disable MCCP compression, in case the game server is not working correctly | 4.16 |
specialForceGAOff | Workaround option to disable Telnet Go-Ahead, in case the game server is not working correctly | 4.16 |
specialForceCharsetNegotiationOff | Workaround option to disable automatically setting the correct encoding, in case the game server is not working correctly | 4.16 |
specialForceMxpNegotiationOff | Workaround option to disable MXP, in case the game server is not working correctly | 4.16 |
caretShortcut | For visually-impaired players - set the key to switch between input line and main window (can be "none" (default), "tab", "ctrltab", "f6") | 4.17 |
blankLinesBehaviour | For visually impaired players options for dealing with blank lines (can be "show" (default), "hide", "replacewithspace") | 4.17 |
- Returns
- true if successful, or nil+msg if the option doesn't exist. Setting mapper options requires the mapper being open first.
- Example
setConfig("mapRoomSize", 5)
setConfig({mapRoomSize = 6, mapExitSize = 12})
getCustomLoginTextId, PR #3952 open
- getCustomLoginTextId()
Returns the Id number of the custom login text setting from the profile's preferences. Returns 0 if the option is disabled or a number greater than that for the item in the table; note it is possible if using an old saved profile in the future that the number might be higher than expected. As a design policy decision it is not permitted for a script to change the setting, this function is intended to allow a script or package to check that the setting is what it expects.
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function, a replacement for which is shown below.
Note: Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
Only one custom login text has been defined initially:
Id | Custom text | Introduced in Mudlet version |
---|---|---|
1 | "connect {character name} {password}" | TBD |
The addition of further texts would be subject to negotiation with the Mudlet Makers.
- Example
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
function doLogin()
if getCustomLoginTextId() ~= 1 then
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
else
tempTime(2.0, [[sendCustomLoginText()]], 1)
end
end
sendCharacterName, PR #3952 open
- sendCharacterName()
Sends the name entered into the "Character name" field on the Connection Preferences form directly to the game server. Returns true unless there is nothing set in that entry in which case a nil and an error message will be returned instead.
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function that may be replaced for more sophisticated requirements.
- See also: getCharacterName(), sendCharacterPassword(), sendCustomLoginText(), getCustomLoginTextId().
Note: Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
sendCharacterPassword, PR #3952 open
- sendCharacterPassword()
Sends the password entered into the "Password" field on the Connection Preferences form directly to the game server. Returns true unless there is nothing set in that entry or it is too long after (or before) a connection was successfully made in which case a nil and an error message will be returned instead.
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function, reproduced below, that may be replaced for more sophisticated requirements.
Note: Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
- Example
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
function doLogin()
if getCharacterName() ~= "" then
tempTime(2.0, [[sendCharacterName()]], 1)
tempTime(3.0, [[sendCharacterPassword()]], 1)
end
end
sendCustomLoginText, PR #3952 open
- sendCustomLoginText()
Sends the custom login text (which does NOT depend on the user's choice of GUI language) selected in the preferences for this profile. The {password} (and {character name} if present) fields will be replaced with the values entered into the "Password" and "Character name" fields on the Connection Preferences form and then sent directly to the game server. Returns true unless there is nothing set in either of those entries (though only if required for the character name) or it is too long after (or before) a connection was successfully made or if the custom login feature is disabled, in which case a nil and an error message will be returned instead.
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function, a replacement for which is shown below.
Note: Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
Only one custom login text has been defined initially:
Id | Custom text | Introduced in Mudlet version |
---|---|---|
1 | "connect {character name} {password}" | TBD |
The addition of further texts would be subject to negotiation with the Mudlet Makers.
- Example
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
function doLogin()
if getCustomLoginTextId() ~= 1 then
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
else
tempTime(2.0, [[sendCustomLoginText()]], 1)
end
end
getConsoleBufferSize, PR #6382 open
- getConsoleBufferSize([consoleName])
- Gets the maximum number of lines a buffer (main window, a user-window, a miniconsole or a buffer) can hold and the number of lines deleted each time that limit is reached. The default values for all types are respectively 10,000 and 1,000.
- Returns two numbers on success, nil and an error message on failure.
- Parameters
- consoleName:
- (optional) The name of the window. If omitted, uses the main console.
- Example
-- there are some preset minimum values below which the end-user cannot set them
display(getConsoleBufferSize())
-- those current minimums produce the following values:
100
10
getConfig, PR #6564 open
- getConfig([option])
- Returns configuration options similar to those that can be set with setConfig. One could use this to decide if a script should notify the user of suggested changes.
See also: setConfig()
- Parameters
- option:
- Particular option to retrieve - see list below for available ones.
Option | Description | Available in Mudlet |
---|---|---|
enableGMCP | Enable GMCP | 4.17 |
enableMSDP | Enable MSDP | 4.17 |
enableMSSP | Enable MSSP | 4.17 |
enableMSP | Enable MSP | 4.17 |
Option | Description | Available in Mudlet |
---|---|---|
inputLineStrictUnixEndings | Workaround option to use strict UNIX line endings for sending commands | 4.17 |
Option | Description | Available in Mudlet |
---|---|---|
fixUnnecessaryLinebreaks | Remove extra linebreaks from output (mostly for IRE servers) | 4.17 |
Option | Description | Available in Mudlet |
---|---|---|
mapRoomSize | Size of rooms on map | 4.17 |
mapExitSize | Size of exits on map | 4.17 |
mapRoundRooms | Draw rooms round or square | 4.17 |
showRoomIdsOnMap | Show room IDs on all rooms | 4.17 |
show3dMapView | Show map as 3D | 4.17 |
mapperPanelVisible | Map controls at the bottom | 4.17 |
mapShowRoomBorders | Draw a thin border for every room | 4.17 |
Option | Description | Available in Mudlet |
---|---|---|
specialForceCompressionOff | Workaround option to disable MCCP compression, in case the game server is not working correctly | 4.17 |
specialForceGAOff | Workaround option to disable Telnet Go-Ahead, in case the game server is not working correctly | 4.17 |
specialForceCharsetNegotiationOff | Workaround option to disable automatically setting the correct encoding, in case the game server is not working correctly | 4.17 |
specialForceMxpNegotiationOff | Workaround option to disable MXP, in case the game server is not working correctly | 4.17 |
caretShortcut | For visually-impaired players - get the key to switch between input line and main window (can be "none", "tab", "ctrltab", "f6") | 4.17 |
blankLinesBehaviour | For visually impaired players options for dealing with blank lines (can be "show", "hide", "replacewithspace") | 4.17 |
- Returns
- It returns a full table of options or the value of the option requested. They are only the configuration options, for example "enableGMCP" means that the "Enable GMCP" box is checked and does not mean that it has been negotiated with the server.
- Example
getConfig()
-- Suggest enabling GMCP if it is unchecked
if not getConfig("enableGMCP") then
echo("\nMy script works best with GMCP enabled. You may ")
cechoLink("<red>click here", function() setConfig("enableGMCP",true) echo("GMCP enabled\n") end, "Enable GMCP", true)
echo(" to enable it.\n")
end
Mudlet Object Functions
- A collection of functions that manipulate Mudlets scripting objects - triggers, aliases, and so forth.
Networking Functions
- A collection of functions for managing networking.
String Functions
- These functions are used to manipulate strings.
Table Functions
- These functions are used to manipulate tables. Through them you can add to tables, remove values, check if a value is present in the table, check the size of a table, and more.
Text to Speech Functions
- These functions are used to create sound from written words. Check out our Text-To-Speech Manual for more detail on how this all works together.
UI Functions
- These functions are used to construct custom user GUIs. They deal mainly with miniconsole/label/gauge creation and manipulation as well as displaying or formatting information on the screen.
setCommandBackgroundColor
- setCommandBackgroundColor([windowName], r, g, b, [transparency])
- Sets the background color for echo of commands. Colors are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
- Parameters
- windowName:
- (optional) name of the label/miniconsole/userwindow to change the background color on, or "main" for the main window.
- r:
- Amount of red to use, from 0 (none) to 255 (full).
- g:
- Amount of green to use, from 0 (none) to 255 (full).
- b:
- Amount of red to use, from 0 (none) to 255 (full).
- transparency:
- (optional) amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Defaults to 255 if omitted.
- Example
-- make a red command background color in main console.
setCommandBackgroundColor(255,0,0,200)
setCommandForegroundColor
- setCommandForegroundColor([windowName], r, g, b, [transparency])
- Sets the foreground color for echo of commands. Colors are from 0 to 255 (0 being black), and transparency is from 0 to 255 (0 being completely transparent).
- Parameters
- windowName:
- (optional) name of the label/miniconsole/userwindow to change the background color on, or "main" for the main window.
- r:
- Amount of red to use, from 0 (none) to 255 (full).
- g:
- Amount of green to use, from 0 (none) to 255 (full).
- b:
- Amount of red to use, from 0 (none) to 255 (full).
- transparency:
- (optional) amount of transparency to use, from 0 (fully transparent) to 255 (fully opaque). Defaults to 255 if omitted.
- Example
-- make a red command foreground color in main console.
setCommandForegroundColor(255,0,0,200)
getScroll, PR #6406 closed
- getScroll([windowName])
- Returns line that the window is currently scrolled to.
- See also: scrollTo, scrollUp, scrollDown
- Parameters
- windowName:
- (optional) name of the window to ask about. Default is the main window.
- Example
-- button to jump to next instance of "Timbo"
local current = getScroll()
local data = getLines(current, getLineCount())
for count, line in ipairs(data) do
local match = string.findPattern(line, "Timbo")
if match then
scrollTo(current + count)
break
end
end
scrollDown, PR #6406 closed
- scrollDown([windowName,] [lines])
- Scrolls down in window by a certain number of lines.
- See also: getScroll, scrollTo, scrollUp
- Parameters
- windowName:
- (optional) name of the window in which to scroll. Default is the main window.
- lines:
- (optional) how many lines to scroll by. Default is 1.
- Example
-- scroll down by 7 lines
scrollDown(7)
scrollUp, PR #6406 closed
- scrollUp([windowName,] [lines])
- Scrolls up in window by a certain number of lines.
- See also: getScroll, scrollTo, scrollDown
- Parameters
- windowName:
- (optional) name of the window in which to scroll. Default is the main window.
- lines:
- (optional) how many lines to scroll by. Default is 1.
- Example
-- scroll up by 7 lines
scrollUp(7)
scrollTo, PR #6406 closed
- scrollTo([windowName,] [lineNumber])
- Scrolls window to a specific line in the buffer.
- Parameters
- windowName:
- (optional) name of the window in which to scroll. Default is the main window.
- lineNumber:
- (optional) target line to scroll to, counting from the top of buffer or with negative numbers to count from the end of buffer. Default is the end of the buffer, to stop scrolling.
- See also: getScroll, scrollUp, scrollDown
- Example
-- scroll to line 42 in buffer
scrollTo(42)
-- start of session
scrollTo(0)
-- 20 lines ago
scrollTo(-20)
-- chat window to line 30
scrollTo("chat", 30)
-- stop scrolling main window
scrollTo()
-- stop scrolling chat window
scrollTo("chat")
Discord Functions
- All functions to customize the information Mudlet displays in Discord's rich presence interface. For an overview on how all of these functions tie in together, see our Discord scripting overview.
Events
- New or revised events that Mudlet can raise to inform a profile about changes. See Mudlet-raised events for the existing ones.