Difference between revisions of "User:Molideus"

From Mudlet
Jump to navigation Jump to search
 
(31 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{TOC right}}
 
{{TOC right}}
{{#description2:Mudlet API documentation for functions for managing networking.}}
 
= Networking Functions =
 
A collection of functions for managing networking.
 
  
==connectToServer==
+
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 [[Manual:Lua_Functions|Lua Functions]] and its sub-sites.  
;connectToServer(host, port, [save])
 
: Connects to a given game.
 
  
;Parameters:
+
Please use the [[Area_51/Template]] to add new entries in the sections below.
* ''host:''
 
: Server domain or IP address.
 
* ''port:''
 
: Servers port.
 
* ''save:''
 
: (optional, boolean) if provided, saves the new connection parameters in the profile so they'll be used next time you open it.
 
  
{{note}} ''save'' is available in Mudlet 3.2+.
+
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.
 +
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki>
 +
rather than:
 +
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki>
 +
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!
  
;Example
+
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.
<syntaxhighlight lang="lua">
+
 
connectToServer("midnightsun2.org", 3000)
+
 
 +
=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.
  
-- save to disk so these parameters are used next time when opening the profile
+
=Database Functions=
connectToServer("midnightsun2.org", 3000, true)
+
:A collection of functions for helping deal with the database.
</syntaxhighlight>
 
  
==disconnect==
+
=Date/Time Functions=
;disconnect()
+
: A collection of functions for handling date & time.
: Disconnects you from the game right away. Note that this will ''not'' properly log you out of the game - use an ingame command for that. Such commands vary, but typically QUIT will work.
 
  
: See also: [[Manual:Networking_Functions#reconnect|reconnect()]]
+
=File System Functions=
;Example
+
: A collection of functions for interacting with the file system.
<syntaxhighlight lang="lua">
 
disconnect()
 
</syntaxhighlight>
 
  
==downloadFile==
+
=Mapper Functions=
;downloadFile(saveto, url)
+
: A collection of functions that manipulate the mapper and its related features.
: Downloads the resource at the given url into the saveto location on disk. This does not pause the script until the file is downloaded - instead, it lets it continue right away and downloads in the background. When a download is finished, the [[Manual:Event_Engine#sysDownloadDone|sysDownloadDone]] event is raised (with the saveto location as the argument), or when a download fails, the [[Manual:Event_Engine#sysDownloadError|sysDownloadError]] event is raised with the reason for failure. You may call downloadFile multiple times and have multiple downloads going on at once - but they aren’t guaranteed to be downloaded in the same order that you started them in.
 
  
:See also: [[#getHTTP|getHTTP()]], [[#postHTTP|postHTTP()]], [[#putHTTP|putHTTP()]], [[#deleteHTTP|deleteHTTP()]]
+
==updateMap==
 +
;updateMap()
  
[[File:Downloadfile privacy logging.png|frame|For privacy transparency, URLs accessed are logged in the Central Debug Console]]
+
:Updates the mapper display (redraws it). While longer necessary since Mudlet 4.18, you can use this this function to redraw the map after changing it via API.
  
{{note}} Since Mudlet 3.0, https downloads are supported and the actual url that was used for the download is returned - useful in case of redirects.
+
: See also: [[#centerview|centerview()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- just download a file and save it in our profile folder
+
-- delete a some room
local saveto = getMudletHomeDir().."/dark-theme-mudlet.zip"
+
deleteRoom(500)
local url = "http://www.mudlet.org/wp-content/files/dark-theme-mudlet.zip"
+
-- now make the map show that it's gone
downloadFile(saveto, url)
+
updateMap()
cecho("<white>Downloading <green>"..url.."<white> to <green>"..saveto.."\n")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
 +
==mapSymbolFontInfo, PR #4038 closed==
 +
;mapSymbolFontInfo()
 +
: See also: [[#setupMapSymbolFont|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).
  
A more advanced example that downloads a webpage, reads it, and prints a result from it:
+
==moveMapLabel, PR #6014 open==
<syntaxhighlight lang="lua">
+
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
-- create a function to parse the downloaded webpage and display a result
+
Re-positions a map label within an area in the 2D mapper, in a similar manner as the [[#moveRoom|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).
function downloaded_file(_, filename)
+
 
  -- is the file that downloaded ours?
+
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].
  if not filename:find("achaea-who-count.html", 1, true) then return end
+
 
 +
{{MudletVersion| ?.??}}
  
  -- read the contents of the webpage in
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014
  local f, s, webpage = io.open(filename)
 
  if f then webpage = f:read("*a"); io.close(f) end
 
  -- delete the file on disk, don't clutter
 
  os.remove(filename)
 
  
  -- parse our downloaded file for the player count
+
;Parameters
  local pc = webpage:match([[Total: (%d+) players online]])
+
* ''areaID/Name:''
  display("Achaea has "..tostring(pc).." players on right now.")
+
: Area ID as number or AreaName as string containing the map label.
end
 
  
-- register our function to run on the event that something was downloaded
+
* ''labelID/Text:''
registerAnonymousEventHandler("sysDownloadDone", "downloaded_file")
+
: 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.
  
-- download a list of fake users for a demo
+
* ''coordX/deltaX:''
downloadFile(getMudletHomeDir().."/achaea-who-count.html", "https://www.achaea.com/game/who")
+
: 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.
</syntaxhighlight>
 
  
Result should look like this:
+
* ''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.
  
[[File:DownloadFile_demo.png|alt=|1000x1000px]].
+
* ''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.
  
==getConnectionInfo==
+
* ''absoluteNotRelativeMove:''
;getConnectionInfo()
+
: (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 the server address and port that you're currently connected to, and (in Mudlet 4.12+) <code>true</code> or <code>false</code> indicating if you're currently connected to a game.
 
:See also: [[Manual:Networking_Functions#connectToServer|connectToServer()]]
 
  
{{MudletVersion|4.2}}
+
;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
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local host, port, connected = getConnectionInfo()
+
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
cecho(string.format("<light_grey>Playing on <forest_green>%s:%s<light_grey>, currently connected? <forest_green>%s\n", host, port, tostring(connected)))
+
moveMapLabel(0, 2, 3.0, 4.0)
</syntaxhighlight>
+
 
 +
-- 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)
  
<syntaxhighlight lang="lua">
+
-- 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**:
-- echo the new connection parameters whenever we connect to a different host with connectToServer()
+
moveRoom(1, 2, -3.5, -2.0, true)
function echoInfo()
 
    local host, port = getConnectionInfo()
 
    cecho(string.format("<light_grey>Now connected to <forest_green>%s:%s\n", host, port))
 
  end
 
  
registerAnonymousEventHandler("sysConnectionEvent", "echoInfo")
+
-- move the second label in the area with the ID number of 2, up three levels
</syntaxhighlight>
+
moveRoom(1, 2, 0.0, 0.0, 3.0)
  
==getIrcChannels==
+
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded
;getIrcChannels()
+
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)
:Returns a list of channels the IRC client is joined to as a lua table. If the client is not yet started the value returned is loaded from disk and represents channels the client will auto-join when started.
 
:See also: [[Manual:Networking_Functions#setIrcChannels|setIrcChannels()]]
 
  
{{MudletVersion|3.3}}
+
-- 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)
  
;Example
+
-- all of the above will return the 'true'  boolean value assuming there are the indicated labels and areas
<syntaxhighlight lang="lua">
 
display(getIrcChannels())
 
-- Prints: {"#mudlet", "#lua"}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getIrcConnectedHost==
+
==moveRoom, PR #6010 open==
;getIrcConnectedHost()
+
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
:Returns true+host where host is a string containing the host name of the IRC server, as given to the client by the server while starting the IRC connection. If the client has not yet started or finished connecting this will return false and an empty string.
+
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 [[Manual:Mapper_Functions#setRoomCoordinates|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.
  
:This function can be particularly useful for testing if the IRC client has connected to a server prior to sending data, and it will not auto-start the IRC client.<br /> 
+
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]
:The ''hostname'' value this function returns can be used to test if [[Manual:Event_Engine#sysIrcMessage|sysIrcMessage]] events are sent from the server or a user on the network.
 
  
;Example
+
{{MudletVersion| ?.??}}
<syntaxhighlight lang="lua">
 
local status, hostname = getIrcConnectedHost()
 
  
if status == true then
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010
  -- do something with connected IRC, send IRC commands, store 'hostname' elsewhere.
 
  -- if sysIrcMessage sender = hostname from above, message is likely a status, command response, or an error from the Server.
 
else
 
  -- print a status, change connection settings, or just continue waiting to send IRC data.
 
end
 
</syntaxhighlight>
 
  
{{MudletVersion|3.3}}
+
;Parameters
 +
* ''roomID:''
 +
: Room ID number to move.
  
==getIrcNick==
+
* ''coordX/deltaX:''
;getIrcNick()
+
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.
:Returns a string containing the IRC client nickname. If the client is not yet started, your default nickname is loaded from IRC client configuration.
 
:See also: [[Manual:Networking_Functions#setIrcNick|setIrcNick()]]
 
  
{{MudletVersion|3.3}}
+
* ''coordY/deltaY:''
 +
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.
  
;Example
+
* ''coordZ/deltaZ:''
<syntaxhighlight lang="lua">
+
: (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.
local nick = getIrcNick()
 
echo(nick)
 
-- Prints: "Sheldor"
 
</syntaxhighlight>
 
  
==getIrcServer==
+
* ''absoluteNotRelativeMove:''
;getIrcServer()
+
: (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 the IRC client server name and port as a string and a number respectively. If the client is not yet started your default server is loaded from IRC client configuration.
 
:See also: [[Manual:Networking_Functions#setIrcServer|setIrcServer()]]
 
  
{{MudletVersion|3.3}}
+
;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
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local server, port = getIrcServer()
+
-- move the first room one space to the east and two spaces to the north
echo("server: "..server..", port: "..port.."\n")
+
moveRoom(1, 1, 2)
</syntaxhighlight>
 
  
==getNetworkLatency==
+
-- move the first room one space to the west, note the final boolean argument is unneeded
; getNetworkLatency()
+
moveRoom(1, -1, 0, false)
: Returns the last measured response time between the sent command and the server reply in seconds - e.g. 0.058 (=58 milliseconds lag) or 0.309 (=309 milliseconds). This is the ''N:'' number you see bottom-right of Mudlet.
 
  
Also known as server lag.
+
-- 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)
  
;Example
+
-- move the second room up three levels
''Need example''
+
moveRoom(2, 0, 0, 3)
  
==openUrl==
+
-- move the second room one space to the west, note the last two arguments are unneeded
;openUrl (url)
+
moveRoom(2, -1, 0, 0, false)
:Opens the default OS browser for the given URL.
 
  
;Example:
+
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:
<syntaxhighlight lang="lua">
+
moveRoom(2, 0, 0, 0, true)
openUrl("http://google.com")
 
openUrl("www.mudlet.org")
 
</syntaxhighlight>
 
  
==reconnect==
+
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers
;reconnect()
 
: Force-reconnects (so if you're connected, it'll disconnect) you to the game.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- you could trigger this on a log out message to reconnect, if you'd like
 
reconnect()
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==restartIrc==
+
==setupMapSymbolFont, PR #4038 closed==
;restartIrc()
+
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
:Restarts the IRC client connection, reloading configurations from disk before reconnecting the IRC client.
+
:configures the font used for symbols in the (2D) map.
 +
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]
  
{{MudletVersion|3.3}}
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
  
==sendAll==
+
;Parameters
; sendAll(list of things to send, [echo back or not])
+
* ''fontName'' one of:
: sends multiple things to the game. If you'd like the commands not to be shown, include ''false'' at the end.
+
:* - 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.
  
:See also: [[Manual:Basic_Essentials#send|send()]]
+
;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).
  
;Example
+
=Miscellaneous Functions=
<syntaxhighlight lang="lua">
+
: Miscellaneous functions.
-- instead of using many send() calls, you can use one sendAll
 
sendAll("outr paint", "outr canvas", "paint canvas")
 
-- can also have the commands not be echoed
 
sendAll("hi", "bye", false)
 
</syntaxhighlight>
 
  
==sendATCP==
+
==compare, PR#7122 open==
;sendATCP(message, what)
 
: ''Need description''
 
  
: See also: [[Manual:Supported_Protocols#ATCP|ATCP Protocol]], [[Manual:ATCP_Extensions|ATCP Extensions]], [http://www.ironrealms.com/rapture/manual/files/FeatATCP-txt.html Achaea Telnet Client Protocol specification], [https://forums.mudlet.org/viewtopic.php?p=19502#p19502 Description by forum user KaVir (2013)], [https://forums.mudlet.org/viewtopic.php?p=2015#p2015 Description by forum user Iocun (2009)]
+
; sameValue = compare(a, b)
  
;Parameters:
+
:This function takes two items, and compares their values. It will compare numbers, strings, but most importantly it will compare two tables by value, not reference. For instance, ''{} == {}'' is ''false'', but ''compare({}, {})'' is ''true''
* ''message:''
 
: The message that you want to send.
 
* ''what:''
 
: ''Need description''
 
  
;Example
+
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]
''Need example''
 
  
==sendGMCP==
+
{{MudletVersion|4.18}}
;sendGMCP(command)
 
: Sends a GMCP message to the server.  The [http://www.ironrealms.com/gmcp-doc IRE document on GMCP] has information about what can be sent, and what tables it will use, etcetera.
 
: Note that this function is rarely used in practice. For most GMCP modules, the messages are automatically sent by the server when a relevant event happens in the game. For example, LOOKing in your room prompts the server to send the room description and contents, as well as the GMCP message gmcp.Room. A call to sendGMCP would not be required in this case.
 
  
: When playing an IRE game, a call to <code>send(" ")</code> afterwards is necessary due to a bug in the game with compression (MCCP) is enabled.
+
;Parameters
 +
* ''a:''
 +
: The first item to compare
 +
* ''b:''
 +
: The second item to compare
  
: See also: [[Manual:Scripting#GMCP|GMCP Scripting for Discord status]]
+
;Returns
 +
* Boolean true if the items have the same value, otherwise boolean false
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
--This would send "Core.KeepAlive" to the server, which resets the timeout
+
local tblA = { 255, 0, 0 }
sendGMCP("Core.KeepAlive")
+
local tblB = color_table.red
 +
local same = compare(tblA, tblB)
 +
display(same)
 +
-- this will return true
 +
display(tblA == tblB)
 +
-- this will display false, as they are different tables
 +
-- even though they have the same value
 +
</syntaxhighlight>
  
--This would send a request for the server to send an update to the gmcp.Char.Skills.Groups table.
+
; Additional development notes
sendGMCP("Char.Skills.Get {}")
+
This is just exposing the existing _comp function, which is currently the best way to compare two tables by value. --[[User:Demonnic|Demonnic]] ([[User talk:Demonnic|talk]]) 18:51, 7 February 2024 (UTC)
 
 
--This would send a request for the server to send a list of the skills in the
 
--vision group to the gmcp.Char.Skills.List table.
 
  
sendGMCP("Char.Skills.Get " .. yajl.to_string{group = "vision"})
+
==createVideoPlayer, PR #6439==
 +
;createVideoPlayer([name of userwindow], x, y, width, height)
  
--And finally, this would send a request for the server to send the info for
+
: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.
--hide in the woodlore group to the gmcp.Char.Skills.Info table
 
  
sendGMCP("Char.Skills.Get " .. yajl.to_string{group="MWP", name="block"})
+
{{note}} A video player may also be created through use of the [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]], the [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] API command, or adding a Geyser.VideoPlayer object to ones user interface such as the example below.
</syntaxhighlight>
 
  
==sendMSDP==
+
{{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.
;sendMSDP(variable[, value][, value...])
 
: Sends a MSDP message to the server.
 
  
;Parameters:
+
See also: [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous Functions#loadVideoFile|loadVideoFile()]], [[Manual:Miscellaneous Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous Functions#playVideoFile|playVideoFile()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous Functions#stopVideos|stopVideos()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
* ''variable:''
 
: The variable, in MSDP terms, that you want to request from the server.
 
* ''value:''
 
: The variables value that you want to request. You can request more than one value at a time.
 
  
: See Also: [[Manual:Supported_Protocols#MSDP|MSDP support in Mudlet]], [http://tintin.sourceforge.net/msdp/ Mud Server Data Protocol specification]
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- ask for a list of commands, lists, and reportable variables that the server supports
+
-- Create a 300x300 video player in the top-left corner of Mudlet
sendMSDP("LIST", "COMMANDS", "LISTS", "REPORTABLE_VARIABLES")
+
createVideoPlayer(0,0,300,300)
  
-- ask the server to start keeping you up to date on your health
+
-- Alternative examples using Geyser.VideoPlayer
sendMSDP("REPORT", "HEALTH")
+
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)
 +
</syntaxhighlight>
  
-- or on your health and location
+
==loadVideoFile, PR #6439==
sendMSDP("REPORT", "HEALTH", "ROOM_VNUM", "ROOM_NAME")
+
;loadVideoFile(settings table) or loadVideoFile(name, [url])
</syntaxhighlight>
+
:Loads video files from the Internet or the local file system to the "media" folder of the profile for later use with [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] and [[Manual:Miscellaneous_Functions#stopVideos|stopVideos()]]. Although files could be loaded or streamed directly at playing time from [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]], loadVideoFile() provides the advantage of loading files in advance.
  
==sendIrc==
+
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.
;sendIrc(target, message)
 
: Sends a message to an IRC channel or person. Returns ''true''+''status'' if message could be sent or was successfully processed by the client, or ''nil''+''error'' if the client is not ready for sending, and ''false''+''status'' if the client filtered the message or failed to send it for some reason. If the IRC client hasn't started yet, this function will initiate the IRC client and begin a connection.
 
  
To receive an IRC message, check out the [[Manual:Event_Engine#sysIrcMessage|sysIrcMessage event]].
+
{| class="wikitable"
 +
!Required
 +
!Key
 +
!Value
 +
! style="text-align:left;" |Purpose
 +
|- style="color: green;"
 +
| style="text-align:center;" |Yes
 +
|name
 +
|<file name>
 +
| style="text-align:left;" |
 +
*Name of the media file.
 +
*May contain directory information (i.e. weather/maelstrom.mp4).
 +
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")
 +
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")
 +
|- style="color: blue;"
 +
| style="text-align:center;" |Maybe
 +
|url
 +
|<url>
 +
| style="text-align:left;" |
 +
*Resource location where the media file may be downloaded.
 +
*Only required if file to load is not part of the profile or on the local file system.
 +
|-
 +
|}
  
{{note}} Since Mudlet 3.3, auto-opens the IRC window and returns the success status.
+
See also: [[Manual:Miscellaneous_Functions#playSoundFile|loadSoundFile()]], [[Manual:Miscellaneous Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous Functions#playVideoFile|playVideoFile()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous Functions#stopVideos|stopVideos()]], [[Manual:Miscellaneous Functions#createVideoPlayer|createVideoPlayer()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
  
;Parameters:
+
{{MudletVersion|4.??}}
* ''target:''
 
: nick or channel name and if omitted will default to the first available channel in the list of joined channels.
 
* ''message:''
 
: The message to send, may contain IRC client commands which start with <code>/</code> and can use all commands which are available through the client window.
 
  
 
;Example
 
;Example
 +
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- this would send "hello from Mudlet!" to the channel #mudlet on freenode.net
+
---- Table Parameter Syntax ----
sendIrc("#mudlet", "hello from Mudlet!")
 
-- this would send "identify password" in a private message to Nickserv on freenode.net
 
sendIrc("Nickserv", "identify password")
 
  
-- use an in-built IRC command
+
-- Download from the Internet
sendIrc("#mudlet", "/topic")
+
loadVideoFile({
</syntaxhighlight>
+
    name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
})
  
{{note}} The following IRC commands are available since Mudlet 3.3:
+
-- OR download from the profile
* /ACTION <target> <message...>
+
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})
* /ADMIN (<server>)
 
* /AWAY (<reason...>)
 
* /CLEAR (<buffer>) -- Clears the text log for the given buffer name. Uses the current active buffer if none are given.
 
* /CLOSE (<buffer>) -- Closes the buffer and removes it from the Buffer list. Uses the current active buffer if none are given.
 
* /HELP (<command>) -- Displays some help information about a given command or lists all available commands.
 
* /INFO (<server>)
 
* /INVITE <user> (<#channel>)
 
* /JOIN <#channel> (<key>)
 
* /KICK (<#channel>) <user> (<reason...>)
 
* /KNOCK <#channel> (<message...>)
 
* /LIST (<channels>) (<server>)
 
* /ME [target] <message...>
 
* /MODE (<channel/user>) (<mode>) (<arg>)
 
* /MOTD (<server>)
 
* /MSG <target> <message...> -- Sends a message to target, can be used to send Private messages.
 
* /NAMES (<#channel>)
 
* /NICK <nick>
 
* /NOTICE <#channel/user> <message...>
 
* /PART (<#channel>) (<message...>)
 
* /PING (<user>)
 
* /RECONNECT -- Issues a Quit command to the IRC Server and closes the IRC connection then reconnects to the IRC server. The same as calling ircRestart() in Lua.
 
* /QUIT (<message...>)
 
* /QUOTE <command> (<parameters...>)
 
* /STATS <query> (<server>)
 
* /TIME (<user>)
 
* /TOPIC (<#channel>) (<topic...>)
 
* /TRACE (<target>)
 
* /USERS (<server>)
 
* /VERSION (<user>)
 
* /WHO <mask>
 
* /WHOIS <user>
 
* /WHOWAS <user>
 
  
{{note}} The following IRC commands are available since Mudlet 3.15:
+
-- OR download from the local file system
* /MSGLIMIT <limit> (<buffer>) -- Sets the limit for messages to keep in the IRC client message buffers and saves this setting.  If a specific buffer/channel name is given the limit is not saved and applies to the given buffer until the application is closed or the limit is changed again.  For this reason, global settings should be applied first, before settings for specific channels/PM buffers.
+
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="lua">
 +
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----
  
==sendTelnetChannel102==
+
-- Download from the Internet
; sendTelnetChannel102(msg)
+
loadVideoFile(
: Sends a message via the 102 subchannel back to the game (that's used in Aardwolf). The msg is in a two byte format; see the link below to the Aardwolf Wiki for how that works.
+
    "TextInMotion-VideoSample-1080p.mp4"
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
)
  
;Example
+
-- OR download from the profile
<syntaxhighlight lang="lua">
+
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")
-- turn prompt flags on:
 
sendTelnetChannel102("\52\1")
 
  
-- turn prompt flags off:
+
-- OR download from the local file system
sendTelnetChannel102("\52\2")
+
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
To see the list of options that Aardwolf supports go to: [http://www.aardwolf.com/blog/2008/07/10/telnet-negotiation-control-mud-client-interaction/ Using Telnet negotiation to control MUD client interaction].
+
==playVideoFile, PR #6439==
 +
;playVideoFile(settings table)
 +
:Plays video files from the Internet or the local file system for later use with [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]]. Video files may be downloaded to the device and played, or streamed from the Internet when the value of the <code>stream</code> parameter is <code>true</code>.
  
==setIrcChannels==
+
{| class="wikitable"
;setIrcChannels(channels)
+
!Required
:Saves the given channels to disk as the new IRC client channel auto-join configuration. This value is not applied to the current active IRC client until it is restarted with [[Manual:Networking_Functions#restartIrc|restartIrc()]]
+
!Key
:See also: [[Manual:Networking_Functions#getIrcChannels|getIrcChannels()]], [[Manual:Networking_Functions#restartIrc|restartIrc()]]
+
!Value
 +
!Default
 +
! style="text-align:left;" |Purpose
 +
|- style="color: green;"
 +
| style="text-align:center;" |Yes
 +
|name
 +
|<file name>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Name of the media file.
 +
*May contain directory information (i.e. weather/maelstrom.mp4).
 +
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")
 +
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")
 +
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
 +
|-
 +
| style="text-align:center;" |No
 +
| volume
 +
|1 to 100
 +
|50
 +
| style="text-align:left;" |
 +
*Relative to the volume set on the player's client.
 +
|-
 +
| style="text-align:center;" |No
 +
|fadein
 +
|<msec>
 +
|
 +
|
 +
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.
 +
*Start position:  Start of media.
 +
*End position:  Start of media plus the number of milliseconds (msec) specified.
 +
*1000 milliseconds = 1 second.
 +
|-
 +
| style="text-align:center;" |No
 +
|fadeout
 +
|<msec>
 +
|
 +
|
 +
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.
 +
*Start position:  End of the media minus the number of milliseconds (msec) specified.
 +
*End position:  End of the media.
 +
*1000 milliseconds = 1 second.
 +
|-
 +
| style="text-align:center;" |No
 +
|start
 +
|<msec>
 +
| 0
 +
| style="text-align:left;" |
 +
*Begin play at the specified position in milliseconds.
 +
|-
 +
| style="text-align:center;" |No
 +
|loops
 +
| -1, or >= 1
 +
|1
 +
| style="text-align:left;" |
 +
*Number of iterations that the media plays.
 +
*A value of -1 allows the media to loop indefinitely.
 +
|-
 +
| style="text-align:center;" |No
 +
|key
 +
|<key>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
 +
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 +
|-
 +
| style="text-align:center;" |No
 +
|tag
 +
|<tag>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Helps categorize media.
 +
|-
 +
| style="text-align:center;" |No
 +
|continue
 +
|true or false
 +
|true
 +
| style="text-align:left;" |
 +
*Continues playing matching new video files when true.
 +
*Restarts matching new video files when false.
 +
|- style="color: blue;"
 +
| style="text-align:center;" |Maybe
 +
|url
 +
|<url>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Resource location where the media file may be downloaded.
 +
*Only required if the file is to be downloaded remotely or for streaming from the Internet.
 +
|- style="color: blue;"
 +
| style="text-align:center;" |Maybe
 +
|stream
 +
|true or false
 +
|false
 +
| style="text-align:left;" |
 +
*Streams files from the Internet when true.
 +
*Download files when false (default).
 +
*Used in combination with the `url` key.
 +
|-
 +
|}
  
;Parameters:
+
See also: [[Manual:Miscellaneous Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous Functions#loadVideoFile|loadVideoFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous Functions#stopVideos|stopVideos()]], [[Manual:Miscellaneous Functions#createVideoPlayer|createVideoPlayer()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
* ''channels:''
 
: A table containing strings which are valid channel names. Any channels in the list which aren't valid are removed from the list.
 
  
{{MudletVersion|3.3}}
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
 +
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setIrcChannels( {"#mudlet", "#lua", "irc"} )
+
---- Table Parameter Syntax ----
-- Only the first two will be accepted, as "irc" is not a valid channel name.
+
 
</syntaxhighlight>
+
-- 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/"
 +
})
  
==setIrcNick==
+
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
;setIrcNick(nickname)
+
playVideoFile({
:Saves the given nickname to disk as the new IRC client configuration. This value is not applied to the current active IRC client until it is restarted with restartIrc()
+
    name = "TextInMotion-VideoSample-1080p.mp4"
:See also: [[Manual:Networking_Functions#getIrcNick|getIrcNick()]], [[Manual:Networking_Functions#restartIrc|restartIrc()]]
+
})
  
;Parameters:
+
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
* ''nickname:''
+
---- [volume] of 75 (1 to 100)
: A string with your new desired name in IRC.
+
playVideoFile({
 +
    name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"
 +
    , volume = 75
 +
})
  
{{MudletVersion|3.3}}
+
-- 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
 +
})
  
;Example
+
-- 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
 +
})
 +
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
setIrcNick( "Sheldor" )
+
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----
</syntaxhighlight>
+
 
 +
-- 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
 +
)
  
==setIrcServer==
+
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
;setIrcServer(hostname, port[, secure])
+
playVideoFile(
:Saves the given server's address to disk as the new IRC client connection configuration. These values are not applied to the current active IRC client until it is restarted with restartIrc()
+
    "TextInMotion-VideoSample-1080p.mp4"  -- name
:See also: [[Manual:Networking_Functions#getIrcServer|getIrcServer()]], [[Manual:Networking_Functions#restartIrc|restartIrc()]]
+
)
  
;Parameters:
+
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
* ''hostname:''
+
---- [volume] of 75 (1 to 100)
: A string containing the hostname of the IRC server.
+
playVideoFile(
* ''port:''
+
    getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name
: (optional) A number indicating the port of the IRC server. Defaults to 6667, if not provided.
+
    , 75 -- volume
* ''secure:''
+
)
: (optional) Boolean, true if server uses Transport Layer Security.  Defaults to false.
 
  
{{MudletVersion|3.3}}
+
-- 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
 +
)
  
;Example
+
-- OR download once from the Internet, and play a video stored in the profile's media directory
<syntaxhighlight lang="lua">
+
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
setIrcServer("irc.libera.chat", 6667)
+
---- [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
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getHTTP==
 
;getHTTP(url, headersTable)
 
: Sends an [https://en.wikipedia.org/wiki/GET_(HTTP) HTTP GET] request to the given URL. Raises [[Manual:Event_Engine#sysGetHttpDone|sysGetHttpDone]] on success or [[Manual:Event_Engine#sysGetHttpError|sysGetHttpError]] on failure.
 
:See also: [[#downloadFile|downloadFile()]].
 
  
[[File:Posthttp privacy logging.png.png|frame|For privacy transparency, URLs accessed are logged in the Central Debug Console]]
+
==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 [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]].
  
;Parameters:
+
{| class="wikitable"
* ''url:''
+
!Required
: Location to send the request to.
+
!Key
* ''headersTable:''
+
!Value
: (optional) table of headers to send with your request.
+
! style="text-align:left;" |Purpose
 +
|-
 +
| style="text-align:center;" |No
 +
| name
 +
| <file name>
 +
| style="text-align:left;" |
 +
* Name of the media file.
 +
|-
 +
| style="text-align:center;" |No
 +
|key
 +
|<key>
 +
| style="text-align:left;" |
 +
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
 +
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 +
|-
 +
| style="text-align:center;" |No
 +
|tag
 +
|<tag>
 +
| style="text-align:left;" |
 +
*Helps categorize media.
 +
|-
 +
|}
  
{{MudletVersion|4.10}}
+
See also: [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadVideoFile|loadVideoFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous Functions#createVideoPlayer|createVideoPlayer()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
 +
 
 +
{{MudletVersion|4.??}}
 +
 
 +
;Example
  
;Examples
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onHttpGetDone(_, url, body)
+
---- Table Parameter Syntax ----
  cecho(string.format("<white>url: <dark_green>%s<white>, body: <dark_green>%s", url, body))
+
 
end
+
-- Stop all playing video files for this profile associated with the API
 +
stopVideos()
  
registerAnonymousEventHandler("sysGetHttpDone", onHttpGetDone)
+
-- Stop playing the text mp4 by name
 +
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})
  
getHTTP("https://httpbin.org/info")
+
-- Stop playing the unique sound identified as "text"
getHTTP("https://httpbin.org/are_you_awesome", {["X-am-I-awesome"] = "yep I am"})
+
stopVideos({
 +
    name = nil  -- nil lines are optional, no need to use
 +
    , key = "text" -- key
 +
    , tag = nil  -- nil lines are optional, no need to use
 +
})
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Status requests typically use GET requests
+
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----
local url = "http://postman-echo.com/status"
 
local header = {["Content-Type"] = "application/json"}
 
  
-- first we create something to handle the success, and tell us what we got
+
-- Stop all playing video files for this profile associated with the API
registerAnonymousEventHandler('sysGetHttpDone', function(event, rurl, response)
+
stopVideos()
  if rurl == url then display(r) else return true end -- this will show us the response body, or if it's not the right url, then do not delete the handler
 
end, true) -- this sets it to delete itself after it fires
 
-- then we create something to handle the error message, and tell us what went wrong
 
registerAnonymousEventHandler('sysGetHttpError', function(event, response, rurl)
 
  if rurl == url then display(r) else return true end -- this will show us the response body, or if it's not the right url, then do not delete the handler
 
end, true) -- this sets it to delete itself after it fires
 
  
-- Lastly, we make the request:
+
-- Stop playing the text mp4 by name
getHTTP(url, header)
+
stopVideos("TextInMotion-VideoSample-1080p.mp4")
  
-- Pop this into an alias and try it yourself!
+
-- Stop playing the unique sound identified as "text"
 +
stopVideos(
 +
    nil -- name
 +
    , "text" -- key
 +
    , nil -- tag
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==postHTTP==
 
;postHTTP(dataToSend, url, headersTable, file)
 
: Sends an [https://en.wikipedia.org/wiki/POST_(HTTP) HTTP POST] request to the given URL, either as text or with a specific file you'd like to upload. Raises [[Manual:Event_Engine#sysPostHttpDone|sysPostHttpDone]] on success or [[Manual:Event_Engine#sysPostHttpError|sysPostHttpError]] on failure.
 
:See also: [[#downloadFile|downloadFile()]], [[#getHTTP|getHTTP()]], [[#putHTTP|putHTTP()]], [[#deleteHTTP|deleteHTTP()]].
 
  
[[File:Posthttp privacy logging.png.png|frame|For privacy transparency, URLs accessed are logged in the Central Debug Console]]
+
==getCustomLoginTextId, PR #3952 open==
 +
;getCustomLoginTextId()
  
;Parameters:
+
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.
* ''dataToSend:''
 
: Text to send in the request (unless you provide a file to upload).
 
* ''url:''
 
: Location to send the request to.
 
* ''headersTable:''
 
: (optional) table of headers to send with your request.
 
* ''file:''
 
: (optional) file to upload as part of the POST request. If provided, this will replace 'dataToSend'.
 
: If you use a scripting language (ex. PHP) to handle this post, remember that the file is sent as raw data. Expecially no field name is provided, dispite it works in common html post.
 
  
{{MudletVersion|4.1}}
+
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.
 +
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].
  
;Examples
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
<syntaxhighlight lang="lua">
 
function onHttpPostDone(_, url, body)
 
  cecho(string.format("<white>url: <dark_green>%s<white>, body: <dark_green>%s", url, body))
 
end
 
  
registerAnonymousEventHandler("sysPostHttpDone", onHttpPostDone)
+
Only one custom login text has been defined initially:
 +
{| class="wikitable"
 +
|+Predefined custom login texts
 +
|-
 +
!Id!!Custom text!!Introduced in Mudlet version
 +
|-
 +
|1||"connect {character name} {password}"||TBD
 +
|}
  
postHTTP("why hello there!", "https://httpbin.org/post")
+
The addition of further texts would be subject to negotiation with the Mudlet Makers.
postHTTP("this us a request with custom headers", "https://httpbin.org/post", {["X-am-I-awesome"] = "yep I am"})
 
postHTTP(nil, "https://httpbin.org/post", {}, "<fill in file location to upload here, maybe get from invokeDialog>")
 
</syntaxhighlight>
 
  
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- This will create a JSON message body. Many modern REST APIs expect a JSON body.  
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
local url = "http://postman-echo.com/post"
+
function doLogin()
local data = {message = "I am the banana", user = "admin"}
+
  if getCustomLoginTextId() ~= 1 then
local header = {["Content-Type"] = "application/json"}
+
    -- 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
 +
</syntaxhighlight>
  
-- first we create something to handle the success, and tell us what we got
+
==sendCharacterName, PR #3952 open==
registerAnonymousEventHandler('sysPostHttpDone', function(event, rurl, response)
+
;sendCharacterName()
  if rurl == url then display(response) else return true end -- this will show us the response body, or if it's not the right url, then do not delete the handler
 
end, true) -- this sets it to delete itself after it fires
 
  
-- then we create something to handle the error message, and tell us what went wrong
+
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.
registerAnonymousEventHandler('sysPostHttpError', function(event, response, rurl)
 
  if rurl == url then display(response) else return true end -- this will show us the response body, or if it's not the right url, then do not delete the handler
 
end, true) -- this sets it to delete itself after it fires
 
  
-- Lastly, we make the request:
+
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.
postHTTP(yajl.to_string(data), url, header) -- yajl.to_string converts our Lua table into a JSON-like string so the server can understand it
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
  
-- Pop this into an alias and try it yourself!
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
</syntaxhighlight>
 
  
;HTTP Basic Authentication Example:
+
==sendCharacterPassword, PR #3952 open==
If your HTTP endpoint requires authentication to post data, HTTP Basic Authentication is a common method for doing so. There are two ways to do so.
+
;sendCharacterPassword()
  
OPTION 1: URL encoding:
+
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.
Many HTTP servers allow you to enter a HTTP Basic Authentication username and password at the beginning of the URL itself, in format:
 
https://username:password@domain.com/path/to/endpoint
 
  
OPTION 2: Authorization Header:
+
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.
Some HTTP servers may require you to put your Basic Authentication into the 'Authorization' HTTP header value.
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].
  
This requires encoding the username:password into base64.
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
For example, if your username is 'user' and your password is '12345', you'd need to run the string "user:12345" through a base64 encoder, which would result in the string:
 
dXNlcjoxMjM0NQ==
 
  
Then, you'd need to set the HTTP header 'Authorization' field value to indicate it is using Basic auth and inserting the base64 string as:
+
;Example
['Authorization'] = "Basic dXNlcjoxMjM0NQ=="
+
<syntaxhighlight lang="lua">
 +
-- 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
 +
</syntaxhighlight>
  
As you're encoding your username and password, you probably want to do this encoding locally for security reasons. You also probably want to only use https:// and not http:// when sending usernames and passwords over the internet.
+
==sendCustomLoginText, PR #3952 open ==
 +
;sendCustomLoginText()
  
In the HTTP Basic Authentication example below, there is an inline base64Encode() function included:
+
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.
  
<syntaxhighlight lang="lua">
+
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.
function base64Encode(data)
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
  -- Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss <alexthkloss@web.de>
+
 
  -- licensed under the terms of the LGPL2
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
  local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
 
    return ((data:gsub('.', function(x)  
 
        local r,b='',x:byte()
 
        for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
 
        return r;
 
    end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
 
        if (#x < 6) then return '' end
 
        local c=0
 
        for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
 
        return b:sub(c+1,c+1)
 
    end)..({ '', '==', '=' })[#data%3+1])
 
end
 
-- Example: base64Encode("user:12345") -> dXNlcjoxMjM0NQ==
 
  
function postJSON(url,dataTable,headerTable)
+
Only one custom login text has been defined initially:
  -- This will create a JSON message body. Many modern REST APIs expect a JSON body.
+
{| class="wikitable"
  local data = dataTable or {text = "hello world"}
+
|+Predefined custom login texts
  local header = headerTable or {["Content-Type"] = "application/json"}
+
|-
  -- first we create something to handle the success, and tell us what we got
+
!Id!!Custom text!!Introduced in Mudlet version
  registerAnonymousEventHandler('sysPostHttpDone', function(event, rurl, response)
+
|-
    if rurl == url then sL("HTTP response success"); echo(response) else return true end -- this will show us the response body, or if it's not the right url, then do not delete the handler
+
|1||"connect {character name} {password}"||TBD
  end, true) -- this sets it to delete itself after it fires
+
|}
  -- then we create something to handle the error message, and tell us what went wrong
 
  registerAnonymousEventHandler('sysPostHttpError', function(event, response, rurl)
 
    if rurl == url then sL("HTTP response error",3); echo(response) else return true end -- this will show us the response body, or if it's not the right url, then do not delete the handler
 
  end, true) -- this sets it to delete itself after it fires
 
  -- Lastly, we make the request:
 
  postHTTP(yajl.to_string(data), url, header) -- yajl.to_string converts our Lua table into a JSON-like string so the server can understand it
 
end
 
  
data = {
+
The addition of further texts would be subject to negotiation with the Mudlet Makers.
    message = "I am the banana",
 
    user = "admin"
 
}
 
header = {
 
    ["Content-Type"] = "application/json",
 
    ["Authorization"] = "Basic " .. base64Encode("user:12345")
 
}
 
postJSON("http://postman-echo.com/post",data,header)
 
</syntaxhighlight>
 
  
;URL Encoding vs JSON encoding
+
;Example
Some HTTP endpoints may not support JSON encoding, and instead may require URL encoding. Here's an example function to convert your lua data table into a URL encoded string::
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Example: URLEncodeTable({message="hello",person="world"}) -> "message=hello&person=world"
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
 
+
function doLogin()
function URLEncodeTable(Args)
+
   if getCustomLoginTextId() ~= 1 then
  -- From: https://help.interfaceware.com/code/details/urlcode-lua
+
    -- 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")
  -- URL-encode the elements of a table creating a string to be used in a
+
   else
  -- URL for passing data/parameters to another script
+
     tempTime(2.0, [[sendCustomLoginText()]], 1)
  -- @param args Table where to extract the pairs (name=value).
 
  -- @return String with the resulting encoding.
 
  ----------------------------------------------------------------------------
 
  --
 
  local ipairs, next, pairs, tonumber, type = ipairs, next, pairs, tonumber, type
 
  local string = string
 
  local table = table
 
 
 
  --helper functions:  
 
  ----------------------------------------------------------------------------
 
  -- Decode an URL-encoded string (see RFC 2396)
 
  ----------------------------------------------------------------------------
 
  local unescape = function (str)
 
    str = string.gsub (str, "+", " ")
 
    str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end)
 
    return str
 
   end
 
 
 
  ----------------------------------------------------------------------------
 
  -- URL-encode a string (see RFC 2396)
 
  ----------------------------------------------------------------------------
 
  local escape = function (str)
 
    str = string.gsub (str, "([^0-9a-zA-Z !'()*._~-])", -- locale independent
 
        function (c) return string.format ("%%%02X", string.byte(c)) end)
 
    str = string.gsub (str, " ", "+")
 
    return str
 
  end
 
 
 
  ----------------------------------------------------------------------------
 
  -- Insert a (name=value) pair into table [[args]]
 
  -- @param args Table to receive the result.
 
  -- @param name Key for the table.
 
  -- @param value Value for the key.
 
  -- Multi-valued names will be represented as tables with numerical indexes
 
  -- (in the order they came).
 
  ----------------------------------------------------------------------------
 
  local insertfield = function (args, name, value)
 
    if not args[name] then
 
        args[name] = value
 
    else
 
        local t = type (args[name])
 
        if t == "string" then
 
          args[name] = {args[name],value,}
 
        elseif t == "table" then
 
          table.insert (args[name], value)
 
        else
 
          error ("CGILua fatal error (invalid args table)!")
 
        end
 
    end
 
   end
 
  -- end helper functions
 
      
 
  if Args == nil or next(Args) == nil then -- no args or empty args?
 
    return ""
 
  end
 
  local strp = ""
 
  for key, vals in pairs(Args) do
 
    if type(vals) ~= "table" then
 
      vals = {vals}
 
    end
 
    for i,val in ipairs(vals) do
 
      strp = strp.."&"..key.."="..escape(val)
 
    end
 
 
   end
 
   end
  -- remove first &
 
  return string.sub(strp,2)
 
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==putHTTP==
+
=Mudlet Object Functions=
;putHTTP(dataToSend, url, [headersTable], [file])
+
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.
: Sends an [https://en.wikipedia.org/wiki/PUT_(HTTP) HTTP PUT] request to the given URL, either as text or with a specific file you'd like to upload. Raises [[Manual:Event_Engine#sysPutHttpDone|sysPutHttpDone]] on success or [[Manual:Event_Engine#sysPutHttpError|sysPutHttpError]] on failure.
 
:See also: [[#downloadFile|downloadFile()]], [[#getHTTP|getHTTP()]], [[#postHTTP|postHTTP()]], [[#deleteHTTP|deleteHTTP()]].
 
  
[[File:PutHTTP privacy logging.png|frame|For privacy transparency, URLs accessed are logged in the Central Debug Console]]
+
==ancestors, new in PR #6726==
 +
;ancestors(IDnumber, type)
 +
:You can use this function to find out about all the ancestors of something.
  
;Parameters:
+
:Returns a list as a table with the details of each successively distance ancestor (if any) of the given item; the details are in the form of a sub-table, within each containing specifically:
* ''dataToSend:''
+
:* its IDnumber as a number
: Text to send in the request (unless you provide a file to upload).
+
:* its name as a string
* ''url:''
+
:* whether it is active as a boolean
: Location to send the request to.
+
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)
* ''headersTable:''
+
:Returns ''nil'' and an error message if either parameter is not valid
: (optional) table of headers to send with your request.
 
* ''file:''
 
: (optional) file to upload as part of the PUT request. If provided, this will replace 'dataToSend'.
 
  
{{MudletVersion|4.1}}
+
;Parameters
 +
* ''IDnumber:''
 +
: The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.
 +
 
 +
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onHttpPutDone(_, url, body)
+
-- To do
  cecho(string.format("<white>url: <dark_green>%s<white>, body: <dark_green>%s", url, body))
 
end
 
 
 
registerAnonymousEventHandler("sysPutHttpDone", onHttpPutDone)
 
putHTTP("this us a request with custom headers", "https://httpbin.org/put", {["X-am-I-awesome"] = "yep I am"})
 
putHTTP("https://httpbin.org/put", "<fill in file location to upload here>")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==deleteHTTP==
+
==findItems, new in PR #6742==
;deleteHTTP(url, headersTable)
+
;findItems("name", "type"[, exact[, case sensitive]])
: Sends an [https://en.wikipedia.org/wiki/DELETE_(HTTP) HTTP DELETE] request to the given URL. Raises [[Manual:Event_Engine#sysDeleteHttpDone|sysDeleteHttpDone]] on success or [[Manual:Event_Engine#sysDeleteHttpError|sysDeleteHttpError]] on failure.
+
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.
:See also: [[#downloadFile|downloadFile()]], [[#getHTTP|getHTTP()]], [[#postHTTP|postHTTP()]], [[#putHTTP|putHTTP()]].
 
  
[[File:PutHTTP privacy logging.png|frame|For privacy transparency, URLs accessed are logged in the Central Debug Console]]
+
:Returns a list as a table with ids of each Mudlet item that matched or ''nil'' and an error message should an incorrect type string be given.
  
;Parameters:
+
;Parameters
* ''url:''
+
* ''name:''
: Location to send the request to.
+
:The name (as a string) of the item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
* ''headersTable:''
+
* ''type:''
: (optional) table of headers to send with your request.
+
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.
 +
* ''exact:''
 +
:(Optional) a boolean which if omitted or ''true'' specifies to match the given name against the whole of the names for items or only as a sub-string of them. As a side effect, if this is provided and is ''false'' and an empty string (i.e. ''""'') is given as the first argument then the function will return the ID numbers of ''all'' items (both temporary and permanent) of the given type in existence at the time.
 +
* ''case sensitive:''
 +
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.
  
{{MudletVersion|4.1}}
+
;Example
 +
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:
 +
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]
  
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onHttpDeleteDone(_, url, body)
+
-- Should find just the package with the name:
  cecho(string.format("<white>url: <dark_green>%s<white>, body: <dark_green>%s", url, body))
+
lua findItems("echo", "alias")
end
+
{ 3 }
 +
 
 +
-- Should find both the package and the alias - as the latter contains "echo" with another character
 +
lua findItems("echo", "alias", false)
 +
{ 3, 4 }
 +
 
 +
-- Finds the ID numbers of all the aliases:
 +
lua findItems("", "alias", false)
 +
{ 1, 2, 3, 4, 5, 6, 7 }
  
registerAnonymousEventHandler("sysDeleteHttpDone", onHttpDeleteDone)
+
-- Will still find the package with the name "echo" as we are not concerned with the casing now:
 +
lua findItems("Echo", "alias", true, false)
 +
{ 3 }
  
deleteHTTP("https://httpbin.org/delete")
+
-- Won't find the package with the name "echo" now as we are concerned with the casing:
deleteHTTP("https://httpbin.org/delete", {["X-am-I-awesome"] = "yep I am"})
+
lua findItems("Echo", "alias", true, true)
 +
{}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==customHTTP==
+
==isActive, modified by PR #6726==
;customHTTP(method, url, headersTable)
+
;isActive(name/IDnumber, type[, checkAncestors])
: Sends an custom method request to the given URL. Raises [[Manual:Event_Engine#sysCustomHttpDone|sysCustomHttpDone]] on success or [[Manual:Event_Engine#sysCustomHttpError|sysCustomHttpError]] on failure.
+
:You can use this function to check if something, or somethings, are active.  
:See also: [[#downloadFile|downloadFile()]], [[#getHTTP|getHTTP()]], [[#postHTTP|postHTTP()]], [[#putHTTP|putHTTP()]], [[#deleteHTTP|deleteHTTP()]].
+
 
 +
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.
  
;Parameters:
+
;Parameters
* ''method:''
+
* ''name:''
: Http method to use (eg. PATCH, HEAD etc.)
+
:The name (as a string) or, from '''Mudlet 4.17.0''', the ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
* ''dataToSend:''
+
* ''type:''
: Text to send in the request (unless you provide a file to upload).
+
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').
* ''url:''
+
* ''checkAncestors:''
: Location to send the request to.
+
:(Optional) If provided AND ''true'' (considered ''false'' if absent to reproduce behavior of previous versions of Mudlet) then this function will only count an item as active if it '''and''' all its parents (ancestors) are active (from '''Mudlet tbd''').
* ''headersTable:''
 
: (optional) table of headers to send with your request.
 
* ''file:''
 
: (optional) file to upload as part of the PUT request. If provided, this will replace 'dataToSend'.
 
  
{{MudletVersion|4.11}}
+
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
function onCustomHttpDone(_, url, body, method)
+
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")
  cecho(string.format("<white>url: <dark_green>%s<white>, body: <dark_green>%s<white>, method: <dark_green>%s", url, body, method))
+
 
 +
-- Can also be used to check if a specific item is enabled or not.
 +
if isActive("spellname", "trigger") > 0 then
 +
  -- the spellname trigger is active
 +
else
 +
  -- it is not active
 
end
 
end
 +
</syntaxhighlight>
 +
 +
{{note}} A positive ID number that does not exist will still return a ''0'' value, this is for constancy with the way the function behaves for a name that does not refer to any item either. If necessary the existence of an item should be confirmed with [[#exists|exists(...)]] first.
  
registerAnonymousEventHandler("sysCustomHttpDone", sysCustomHttpDone)
+
==isAncestorsActive, new in PR #6726==
 +
;isAncestorsActive(IDnumber, "type")
 +
:You can use this function to check if '''all''' the ancestors of something are active independent of whether it itself is, (for that use the two argument form of [[#isActive|isActive(...)]]).
  
customHTTP("PATCH", "this us a request with custom headers", "https://httpbin.org/put", {["X-am-I-awesome"] = "yep I am"})
+
:Returns ''true'' if all (if any) of the ancestors of the item with the specified ID number and type are active, if there are no such parents then it will also returns ''true''; otherwise returns ''false''. In the event that an invalid type string or item number is provided returns ''nil'' and an error message.
customHTTP("PATCH", "https://httpbin.org/put", "<fill in file location to upload here>")
+
 
 +
;Parameters
 +
* ''IDnumber:''
 +
:The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.
 +
 
 +
:See also: [[#exists|exists(...)]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- To do
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==sendSocket==
+
=Networking Functions=
 
+
:A collection of functions for managing networking.
 +
==sendSocket revised in PR #7066 (Open)==
  
 
;sendSocket(data)
 
;sendSocket(data)
Line 800: Line 905:
 
-- This function is still being written up.
 
-- This function is still being written up.
  
==feedTelnet==
+
==feedTelnet added in PR #7066 (Open)====
 
 
  
 
; feedTelnet(data)
 
; feedTelnet(data)
Line 1,089: Line 1,193:
 
-- This function is still being written up.
 
-- This function is still being written up.
  
[[Category:Mudlet API]]
+
=String Functions=
[[Category:Mudlet Manual]]
+
: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 [[Special:MyLanguage/Manual:Text-to-Speech|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.
 +
 
 +
==cecho2decho PR#6849 merged==
 +
; convertedString = cecho2decho(str)
 +
 
 +
:Converts a cecho formatted string to a decho formatted one.
 +
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from cecho to decho
 +
;Returns
 +
* a string formatted for decho
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to a decho string and use decho to display it
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
decho(cecho2decho(cechoString))
 +
</syntaxhighlight>
 +
 
 +
==cecho2hecho PR#6849 merged==
 +
; convertedString = cecho2hecho(str)
 +
 
 +
:Converts a cecho formatted string to an hecho formatted one.
 +
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from cecho to decho
 +
;Returns
 +
* a string formatted for hecho
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to an hecho string and use hecho to display it
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
hecho(cecho2hecho(cechoString))
 +
</syntaxhighlight>
 +
 
 +
==cecho2html PR#6849 merged==
 +
; convertedString = cecho2html(str[, resetFormat])
 +
 
 +
:Converts a cecho formatted string to an html formatted one.
 +
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from cecho to decho
 +
* ''resetFormat''
 +
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 +
;Returns
 +
* a string formatted for html
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- create the base string
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 +
 
 +
-- create a label to display the result onto
 +
testLabel = Geyser.Label:new({name = "testLabel"})
 +
 
 +
-- convert the cecho string to an html one, using the default formatting of testLabel created above
 +
local htmlString = cecho2html(cechoString, testLabel:getFormat())
 +
 
 +
-- and finally echo it to the label to see
 +
-- I use rawEcho as that displays the html exactly as given.
 +
testLabel:rawEcho(htmlString)
 +
</syntaxhighlight>
 +
 
 +
==decho2cecho PR#6849 merged==
 +
; convertedString = decho2cecho(str)
 +
 
 +
:Converts a decho formatted string to a cecho formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from decho to cecho
 +
;Returns
 +
* a string formatted for cecho
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to a decho string and use cecho to display it
 +
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
 +
cecho(decho2cecho(dechoString))
 +
</syntaxhighlight>
 +
 
 +
==decho2hecho PR#6849 merged==
 +
; convertedString = decho2hecho(str)
 +
 
 +
:Converts a decho formatted string to an hecho formatted one.
 +
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from decho to decho
 +
;Returns
 +
* a string formatted for hecho
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to an hecho string and use hecho to display it
 +
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
 +
hecho(decho2hecho(dechoString))
 +
</syntaxhighlight>
 +
 
 +
==decho2html PR#6849 merged==
 +
; convertedString = decho2html(str[, resetFormat])
 +
 
 +
:Converts a decho formatted string to an html formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from decho to decho
 +
* ''resetFormat''
 +
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 +
;Returns
 +
* a string formatted for html
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- create the base string
 +
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
 +
 
 +
-- create a label to display the result onto
 +
testLabel = Geyser.Label:new({name = "testLabel"})
 +
 
 +
-- convert the decho string to an html one, using the default formatting of testLabel created above
 +
local htmlString = decho2html(dechoString, testLabel:getFormat())
 +
 
 +
-- and finally echo it to the label to see
 +
-- I use rawEcho as that displays the html exactly as given.
 +
testLabel:rawEcho(htmlString)
 +
</syntaxhighlight>
 +
 
 +
==deleteMultiline PR #6779 merged==
 +
 
 +
; ok,err = deleteMultiline([triggerDelta])
 +
 
 +
:Deletes all lines between when the multiline trigger fires and when the first trigger matched. Put another way, it deletes everything since the pattern in slot 1 matched.
 +
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
{{note}} This deletes all the lines since the first match of the multiline trigger matched. Do not use this if you do not want to delete ALL of those lines.
 +
 
 +
;Parameters
 +
* ''[optional]triggerDelta:''
 +
: The line delta from the multiline trigger it is being called from. It is best to pass this in to ensure all lines are caught. If not given it will try to guess based on the number of patterns how many lines at most it might have to delete.
 +
 
 +
;Returns
 +
* true if the function was able to run successfully, nil+error if something went wrong.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- if this trigger has a line delta of 3, you would call
 +
deleteMultiline(3)
 +
 
 +
-- same thing, but with error handling
 +
local ok,err = deleteMultiline(3)
 +
if not ok then
 +
  cecho("\n<firebrick>I could not delete the lines because: " .. err)
 +
end
 +
</syntaxhighlight>
 +
 
 +
; Additional development notes
 +
 
 +
==echoPopup, revised in PR #6946==
 +
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])
 +
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if there is one extra hint then the first one will be used as a (maybe containing Qt rich-text markup) tool-tip for the text otherwise the remaining hints will be concatenated, one-per-line, as a tool-tip when the text is hovered over by the pointer.
 +
 
 +
; Parameters
 +
* ''windowName:''
 +
: (optional) name of the window as a string to echo to. Use either ''main'' or omit for the main window, or the miniconsole's or user-window's name otherwise.
 +
* ''text:''
 +
: the text string to display.
 +
* ''{commands}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>.
 +
* ''{hints}:''
 +
: a table of strings which will be shown on the right-click menu and as a tool-tip for the ''text''. If the number is the same as that of the ''commands'' table then they all will be used for the right-click menu and listed (one per line) as a plain text tooltip; alternatively if there is one extra in number than the ''commands'' table the first will be used purely for the tool tip and the remainder will be used for the right-click menu. This additional entry may be formatted as Qt style "rich-text" (in the same manner as labels elsewhere in the GUI).
 +
::* If a particular position in the ''commands'' table is an empty string ''""'' but there is something in the ''hints'' table then it will be listed in the right-click menu but as it does not do anything it will be shown ''greyed-out'' i.e. disabled and will not be clickable.
 +
::* If a particular position in '''both''' the ''commands'' and the ''hints'' table are empty strings ''""'' then this item will show as a ''separator'' (usually as a horizontal-line) in the right-click menu and it will not be clickable/do anything.
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if ''true'' or the link default (blue underline) if ''false'', if omitted the default format is used.
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
 +
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
 +
 
 +
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
 +
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
 +
 
 +
-- one can also provide helpful information
 +
 
 +
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!
 +
echoPopup("Fancy popup", {[[echo("Doing command 1 (default one)")]], "", "", [[echo("Doing command 3")]], [[echo("Doing another command (number 4)"]], [[echo("Doing another command (number 5)"]])}, {"<p>This tooltip has HTML type tags in/around it, and it will get word-wrapped automatically to fit into a reasonable rectangle.</p><p><b>Plus</b> it can have those HTML like <i>effects</i> and be easily formatted into more than one paragraph and with <span style=\"color:cyan\">bits</span> in <span style=\"color:lime\">different</span> colors!</p><p>This example also demonstrates how to produce disabled menu (right-click) items, how to insert separators and how it now will handle multiple items with the same hint (prior to PR 6945 such duplicates will all run the command associated with the last one!) If the first command/function is an empty string then clicking on the text will have no effect, but hovering the mouse over the text will still produce the tooltip, this could be useful to display extra information about the text without doing anything by default.</p>", "Command 1 (default)", "", "Command 2 (disabled)", "Command 3", "Another command", "Another command"}, true)
 +
echo(" remaining text.\n")
 +
 
 +
</syntaxhighlight>
 +
 
 +
==hecho2cecho PR#6849 merged==
 +
; convertedString = hecho2cecho(str)
 +
 
 +
:Converts a hecho formatted string to a cecho formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from hecho to cecho
 +
;Returns
 +
* a string formatted for cecho
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to a hecho string and use cecho to display it
 +
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
 +
cecho(hecho2cecho(hechoString))
 +
</syntaxhighlight>
 +
 
 +
==hecho2decho PR#6849 merged==
 +
; convertedString = hecho2decho(str)
 +
 
 +
:Converts a hecho formatted string to a decho formatted one.
 +
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
 +
 
 +
{{MudletVersion|4.18}}
 +
 
 +
;Parameters
 +
* ''str''
 +
: string you wish to convert from hecho to decho
 +
;Returns
 +
* a string formatted for decho
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- convert to a decho string and use decho to display it
 +
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
 +
decho(hecho2decho(hechoString))
 +
</syntaxhighlight>
 +
 
 +
=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 [[Special:MyLanguage/Manual:Scripting#Discord_Rich_Presence|Discord scripting overview]].
 +
 
 +
=Mud Client Media Protocol=
 +
:All GMCP functions to send sound and music events. For an overview on how all of these functions tie in together, see our [[Special:MyLanguage/Manual:Scripting#MUD_Client_Media_Protocol|MUD Client Media Protocol scripting overview]].
 +
 
 +
=Supported Protocols=
 +
 
 +
=Events=
 +
:New or revised events that Mudlet can raise to inform a profile about changes. See [[Manual:Event_Engine#Mudlet-raised_events|Mudlet-raised events]] for the existing ones.
 +
 
 +
===sysMapAreaChanged, PR #6615===
 +
Raised when the area being viewed in the mapper is changed, either by the player-room being set to a new area or the user selecting a different area in the area selection combo-box in the mapper controls area. Returns two additional arguments being the areaID of the area being switched to and then the one for the area that is being left.
 +
 
 +
{{MudletVersion| ?.??}}
 +
 
 +
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615
 +
 
 +
===sysMapWindowMousePressEvent, PR #6962===
 +
Raised when the mouse is left-clicked on the mapper window.
 +
 
 +
{{MudletVersion| ?.??}}
 +
 
 +
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962
 +
 
 +
===sysWindowOverflowEvent, PR #6872===
 +
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.
 +
 
 +
{{MudletVersion| ?.??}}
 +
 
 +
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6872 and https://github.com/Mudlet/Mudlet/pull/6848 for the Lua API functions (that also need documenting).

Latest revision as of 07:18, 21 July 2024

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.

updateMap

updateMap()
Updates the mapper display (redraws it). While longer necessary since Mudlet 4.18, you can use this this function to redraw the map after changing it via API.
See also: centerview()
Example
-- delete a some room
deleteRoom(500)
-- now make the map show that it's gone
updateMap()


mapSymbolFontInfo, PR #4038 closed

mapSymbolFontInfo()
See also: setupMapSymbolFont()

Note 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().
Mudlet VersionAvailable in Mudlet ?.??+

Note 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()
Mudlet VersionAvailable in Mudlet ?.??+

Note 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 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.

compare, PR#7122 open

sameValue = compare(a, b)
This function takes two items, and compares their values. It will compare numbers, strings, but most importantly it will compare two tables by value, not reference. For instance, {} == {} is false, but compare({}, {}) is true
See also
table.complement(), table.n_union()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • a:
The first item to compare
  • b:
The second item to compare
Returns
  • Boolean true if the items have the same value, otherwise boolean false
Example
local tblA = { 255, 0, 0 }
local tblB = color_table.red
local same = compare(tblA, tblB)
display(same)
-- this will return true
display(tblA == tblB)
-- this will display false, as they are different tables
-- even though they have the same value
Additional development notes

This is just exposing the existing _comp function, which is currently the best way to compare two tables by value. --Demonnic (talk) 18:51, 7 February 2024 (UTC)

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

Mudlet VersionAvailable in Mudlet4.??+
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 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>
  • Name of the media file.
  • May contain directory information (i.e. weather/maelstrom.mp4).
  • May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")
  • May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")
Maybe url <url>
  • Resource location where the media file may be downloaded.
  • Only required if file to load is not part of the profile or on the local file system.

See also: loadSoundFile(), loadMusicFile(), playSoundFile(), playMusicFile(), playVideoFile(), stopSounds(), stopMusic(), stopVideos(), createVideoPlayer(), purgeMediaCache(), Mud Client Media Protocol

Mudlet VersionAvailable in Mudlet4.??+
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 is true.
Required Key Value Default Purpose
Yes name <file name>  
  • Name of the media file.
  • May contain directory information (i.e. weather/maelstrom.mp4).
  • May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")
  • May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")
  • Wildcards * and ? may be used within the name to randomize media files selection.
No volume 1 to 100 50
  • Relative to the volume set on the player's client.
No fadein <msec>
  • Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.
  • Start position: Start of media.
  • End position: Start of media plus the number of milliseconds (msec) specified.
  • 1000 milliseconds = 1 second.
No fadeout <msec>
  • Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.
  • Start position: End of the media minus the number of milliseconds (msec) specified.
  • End position: End of the media.
  • 1000 milliseconds = 1 second.
No start <msec> 0
  • Begin play at the specified position in milliseconds.
No loops -1, or >= 1 1
  • Number of iterations that the media plays.
  • A value of -1 allows the media to loop indefinitely.
No key <key>  
  • Uniquely identifies media files with a "key" that is bound to their "name" or "url".
  • Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
No tag <tag>  
  • Helps categorize media.
No continue true or false true
  • Continues playing matching new video files when true.
  • Restarts matching new video files when false.
Maybe url <url>  
  • Resource location where the media file may be downloaded.
  • Only required if the file is to be downloaded remotely or for streaming from the Internet.
Maybe stream true or false false
  • Streams files from the Internet when true.
  • Download files when false (default).
  • Used in combination with the `url` key.

See also: loadSoundFile(), loadMusicFile(), loadVideoFile(), playSoundFile(), playMusicFile(), stopSounds(), stopMusic(), stopVideos(), createVideoPlayer(), purgeMediaCache(), Mud Client Media Protocol

Mudlet VersionAvailable in Mudlet4.??+
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>
  • Name of the media file.
No key <key>
  • Uniquely identifies media files with a "key" that is bound to their "name" or "url".
  • Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
No tag <tag>
  • Helps categorize media.

See also: loadSoundFile(), loadMusicFile(), loadVideoFile(), playSoundFile(), playMusicFile(), playVideoFile(), stopSounds(), stopMusic(), createVideoPlayer(), purgeMediaCache(), Mud Client Media Protocol

Mudlet VersionAvailable in Mudlet4.??+
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
)


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.

See also: getCharacterName(), sendCharacterName(), sendCustomLoginText(), sendPassword().

Note Note: Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952

Only one custom login text has been defined initially:

Predefined custom login texts
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 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.

See also: getCharacterName(), sendCustomLoginText(), getCustomLoginTextId(), sendCharacterName().

Note 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.

See also: getCharacterName(), sendCharacterName(), sendPassword(), getCustomLoginTextId().

Note Note: Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952

Only one custom login text has been defined initially:

Predefined custom login texts
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

Mudlet Object Functions

A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.

ancestors, new in PR #6726

ancestors(IDnumber, type)
You can use this function to find out about all the ancestors of something.
Returns a list as a table with the details of each successively distance ancestor (if any) of the given item; the details are in the form of a sub-table, within each containing specifically:
  • its IDnumber as a number
  • its name as a string
  • whether it is active as a boolean
  • its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)
Returns nil and an error message if either parameter is not valid
Parameters
  • IDnumber:
The ID number of a single item, (which will be that returned by a temp* or perm* function to create such an item to identify the item).
  • type:
The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.
See also: isAncestorsActive(...), isActive(...)
Example
-- To do

findItems, new in PR #6742

findItems("name", "type"[, exact[, case sensitive]])
You can use this function to determine the ID number or numbers of items of a particular type with a given name.
Returns a list as a table with ids of each Mudlet item that matched or nil and an error message should an incorrect type string be given.
Parameters
  • name:
The name (as a string) of the item, (which will be that returned by a temp* or perm* function to create such an item to identify the item).
  • type:
The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.
  • exact:
(Optional) a boolean which if omitted or true specifies to match the given name against the whole of the names for items or only as a sub-string of them. As a side effect, if this is provided and is false and an empty string (i.e. "") is given as the first argument then the function will return the ID numbers of all items (both temporary and permanent) of the given type in existence at the time.
  • case sensitive:
(Optional) a boolean which if omitted or true specifies to match in a case-sensitive manner the given name against the names for items.
Example

Given a profile with just the default packages installed (automatically) - including the echo one:

View of standard aliases with focus on echo package.png
-- Should find just the package with the name:
lua findItems("echo", "alias")
{ 3 }

-- Should find both the package and the alias - as the latter contains "echo" with another character
lua findItems("echo", "alias", false)
{ 3, 4 }

-- Finds the ID numbers of all the aliases:
lua findItems("", "alias", false)
{ 1, 2, 3, 4, 5, 6, 7 }

-- Will still find the package with the name "echo" as we are not concerned with the casing now:
lua findItems("Echo", "alias", true, false)
{ 3 }

-- Won't find the package with the name "echo" now as we are concerned with the casing:
lua findItems("Echo", "alias", true, true)
{}

isActive, modified by PR #6726

isActive(name/IDnumber, type[, checkAncestors])
You can use this function to check if something, or somethings, are active.
Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.
Parameters
  • name:
The name (as a string) or, from Mudlet 4.17.0, the ID number of a single item, (which will be that returned by a temp* or perm* function to create such an item to identify the item).
  • type:
The type can be 'alias', 'button' (from Mudlet 4.10), 'trigger', 'timer', 'keybind' (from Mudlet 3.2), or 'script' (from Mudlet 3.17).
  • checkAncestors:
(Optional) If provided AND true (considered false if absent to reproduce behavior of previous versions of Mudlet) then this function will only count an item as active if it and all its parents (ancestors) are active (from Mudlet tbd).
See also: exists(...), isAncestorsActive(...), ancestors(...)
Example
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")

-- Can also be used to check if a specific item is enabled or not.
if isActive("spellname", "trigger") > 0 then
  -- the spellname trigger is active
else
  -- it is not active
end

Note Note: A positive ID number that does not exist will still return a 0 value, this is for constancy with the way the function behaves for a name that does not refer to any item either. If necessary the existence of an item should be confirmed with exists(...) first.

isAncestorsActive, new in PR #6726

isAncestorsActive(IDnumber, "type")
You can use this function to check if all the ancestors of something are active independent of whether it itself is, (for that use the two argument form of isActive(...)).
Returns true if all (if any) of the ancestors of the item with the specified ID number and type are active, if there are no such parents then it will also returns true; otherwise returns false. In the event that an invalid type string or item number is provided returns nil and an error message.
Parameters
  • IDnumber:
The ID number of a single item, (which will be that returned by a temp* or perm* function to create such an item to identify the item).
  • type:
The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.
See also: exists(...)
Example
-- To do

Networking Functions

A collection of functions for managing networking.

sendSocket revised in PR #7066 (Open)

sendSocket(data)
Sends given binary data as-is (or with some predefined special tokens converted to byte values) to the game. You can use this to implement support for a new telnet protocol, simultronics login etc.
success = sendSocket("data")
See also
feedTelnet(), feedTriggers()

Note Note: Modified in Mudlet tbd to accept some tokens like "<NUL>" to include byte values that are not possible to insert with the standard Lua string escape "\###" form where ### is a three digit number between 000 and 255 inclusive or where the value is more easily provided via a mnemonic. For the table of the tokens that are known about, see the one in feedTelnet().

Note Note: The data (as bytes) once the tokens have been converted to their byte values is sent as is to the Game Server; any encoding to, say, a UTF-8 representation or to duplicate 0xff byte values so they are not considered to be Telnet <IAC> (Interpret As Command) bytes must be done to the data prior to calling this function.

Parameters
  • data:
String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.
Returns
  • (Only since Mudlet tbd) Boolean true if the whole data string (after token replacement) was sent to the Server, false if that failed for any reason (including if the Server has not been connected or is now disconnected). nil and an error message for any other defect.
Example
-- Tell the Server that we are now willing and able to process  to process Ask the Server to a comment explaining what is going on, if there is multiple functionalities (or optional parameters) the examples should start simple and progress in complexity if needed!
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
-- comments up top should introduce / explain what it does

local something = function(exampleValue)
if something then
  -- do something with something (assuming there is a meaningful return value)
end

-- maybe another example for the optional second case
local somethingElse = function(exampleValue, anotherValue)

-- lastly, include an example with error handling to give an idea of good practice
local ok, err = function()
if not ok then
  debugc(f"Error: unable to do <particular thing> because {err}\n")
  return
end
Additional development notes

-- This function is still being written up.

feedTelnet added in PR #7066 (Open)==

feedTelnet(data)
Sends given binary data with some predefined special tokens converted to byte values, to the internal telnet engine, as if it had been received from the game. This is primarily to enable testing when new Telnet sub-options/protocols are being developed. The data has to be injected into the system nearer to the point where the Game Server's data starts out than feedTriggers() and unlike the latter the data is not subject to any encoding so as to match the current profile's setting (which normally happens with feedTriggers()). Furthermore - to prevent this function from putting the telnet engine into a state which could damage the processing of real game data it will refuse to work unless the Profile is completely disconnected from the game server.
See also
feedTriggers(), sendSocket()
Mudlet VersionAvailable in Mudlettbd+

Note Note: This is not really intended for end-user's but might be useful in some circumstances.

Parameters
  • data
String containing the bytes to send to the internal telnet engine as if it had come from the Game Server, it can containing some tokens listed below that are to be converted to bytes as well.
Returns
  • Boolean true if the data string was sent to the internal telnet engine. nil and an error message otherwise, specifically the case when there is some traces of a connection or a complete connection to the socket that passes the data to and from the game server. Additionally, if the data is an empty string "" a second return value will be provided as an integer number representing a version for the table of tokens - which will be incremented each time a change is made to that table so that which tokens are valid can be determined. Note that unrecognised tokens should be passed through as is and not get replaced.
Token value table
Token Byte Version Notes
<00> \0x00 1 0 dec.
<O_BINARY> \0x00 1 Telnet option: Binary
<NUL> \0x00 1 ASCII control character: NULL
<01> \x01 1 1 dec.
<O_ECHO> \x01 1 Telnet option: Echo
<SOH> \x01 1 ASCII control character: Start of Heading
<02> \x02 1 2 dec. Telnet option: Reconnect
<STX> \x02 1 ASCII control character: Start of Text
<03> \x03 1 3 dec.
<O_SGA> \x03 1 Telnet option: Suppress Go Ahead
<ETX> \x03 1 ASCII control character: End of Text
<04> \x04 1 Telnet option: Approx Message Size Negotiation
<EOT> \x04 1 ASCII control character: End of Transmission
<05> \x05 1
<O_STATUS> \x05 1
<ENQ> \x05 1 ASCII control character: Enquiry
<06> \x06 1 Telnet option: Timing Mark
<ACK> \x06 1 ASCII control character: Acknowledge
<07> \x07 1 Telnet option: Remote Controlled Trans and Echo
<BELL> \x07 1 ASCII control character: Bell
<08> \x08 1 Telnet option: Output Line Width
<BS> \x08 1
<09> \x09 1 Telnet option: Output Page Size
<HTAB> \x09 1 ASCII control character: Horizontal Tab
<0A> \x0a 1 Telnet option: Output Carriage-Return Disposition
<LF> \x0a 1 ASCII control character: Line-Feed
<0B> \x0b 1 Telnet option: Output Horizontal Tab Stops
<VTAB> \x0b 1 ASCII control character: Vertical Tab
<0C> \x0c 1 Telnet option: Output Horizontal Tab Disposition
<FF> \x0c 1 ASCII control character: Form-Feed
<0D> \x0d 1 Telnet option: Output Form-feed Disposition
<CR> \x0d 1 ASCII control character: Carriage-Return
<0E> \x0e 1 Telnet option: Output Vertical Tab Stops
<SO> \x0e 1 ASCII control character: Shift-Out
<0F> \x0f 1 Telnet option: Output Vertical Tab Disposition
<SI> \x0f 1 ASCII control character: Shift-In
<10> \x10 1 Telnet option: Output Linefeed Disposition
<DLE> \x10 1 ASCII control character: Data Link Escape
<11> \x11 1 Telnet option: Extended ASCII
<DC1> \x11 1 ASCII control character: Device Control 1
<12> \x12 1 Telnet option: Logout
<DC2" \x12 1 ASCII control character: Device Control 2
<13> \x13 1 Telnet option: Byte Macro
<DC3> \x13 1 ASCII control character: Device Control 3
<14> \x14 1 Telnet option: Data Entry Terminal
<DC4> \x14 1 ASCII control character: Device Control 4
<15> \x15 1 Telnet option: SUPDUP
<NAK> \x15 1 ASCII control character: Negative Acknowledge
<16> \x16 1 Telnet option: SUPDUP Output
<SYN> \x16 1 ASCII control character: Synchronous Idle
<17> \x17 1 Telnet option: Send location
<ETB> \x17 1 ASCII control character: End of Transmission Block
<18> \x18 1
<O_TERM> \x18 1 Telnet option: Terminal Type
<CAN> \x18 1 ASCII control character: Cancel
<19> \x19 1
<O_EOR> \x19 1 Telnet option: End-of-Record
<EM> \x19 1 ASCII control character: End of Medium
<1A> \x1a 1 Telnet option: TACACS User Identification
<SUB> \x1a 1 ASCII control character: Substitute
<1B> \x1b 1 Telnet option: Output Marking
<ESC> \x1b 1 ASCII control character: Escape
<1C> \x1c 1 Telnet option: Terminal Location Number
<FS> \x1c 1 ASCII control character: File Separator
<1D> \x1d 1 Telnet option: Telnet 3270 Regime
<GS> \x1d 1 ASCII control character: Group Separator
<1E> \x1e 1 Telnet option: X.3 PAD
<RS> \x1e 1 ASCII control character: Record Separator
<1F> \x1f 1
<O_NAWS> \x1f 1 Telnet option: Negotiate About Window Size
<US> \x1f 1 ASCII control character: Unit Separator
<SP> \x20 1 32 dec. ASCII character: Space
<O_NENV> \x27 1 39 dec. Telnet option: New Environment (also MNES)
<O_CHARS> \x2a 1 42 dec. Telnet option: Character Set
<O_KERMIT> \x2f 1 47 dec. Telnet option: Kermit
<O_MSDP> \x45 1 69 dec. Telnet option: Mud Server Data Protocol
<O_MSSP> \x46 1 70 dec. Telnet option: Mud Server Status Protocol
<O_MCCP> \x55 1 85 dec
<O_MCCP2> \x56 1 86 dec
<O_MSP> \x5a 1 90 dec. Telnet option: Mud Sound Protocol
<O_MXP> \x5b 1 91 dec. Telnet option: Mud eXtension Protocol
<O_ZENITH> \x5d 1 93 dec. Telnet option: Zenith Mud Protocol
<O_AARDWULF> \x66 1 102 dec. Telnet option: Aardwuld Data Protocol
<DEL> \x7f 1 127 dec. ASCII control character: Delete
<O_ATCP> \xc8 1 200 dec
<O_GMCP> \xc9 1 201 dec
<T_EOR> \xef 1 239 dec
<F0> \xf0 1
<T_SE> \xf0 1
<F1> \xf1 1
<T_NOP> \xf1 1
<F2> \xf2 1
<T_DM> \xf2 1
<F3> \xf3 1
<T_BRK> \xf3 1
<F4> \xf4 1
<T_IP> \xf4 1
<F5> \xf5 1
<T_ABOP> \xf5 1
<F6> \xf6 1
<T_AYT> \xf6 1
<F7> \xf7 1
<T_EC> \xf7 1
<F8> \xf8 1
<T_EL> \xf8 1
<F9> \xf9 1
<T_GA> \xf9 1
<FA> \xfa 1
<T_SB> \xfa 1
<FB> \xfb 1
<T_WILL> \xfb 1
<FC> \xfc 1
<T_WONT> \xfc 1
<FD> \xfd 1
<T_DO> \xfd 1
<FE> \xfe 1
<T_DONT> \xfe 1
<FF> \xff 1
<T_IAC> \xff'
Example
-- a comment explaining what is going on, if there is multiple functionalities (or optional parameters) the examples should start simple and progress in complexity if needed!
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
-- comments up top should introduce / explain what it does

local something = feedTelnet(exampleValue)
if something then
  -- do something with something (assuming there is a meaningful return value)
end

-- maybe another example for the optional second case
local somethingElse = function(exampleValue, anotherValue)

-- lastly, include an example with error handling to give an idea of good practice
local ok, err = function()
if not ok then
  debugc(f"Error: unable to do <particular thing> because {err}\n")
  return
end
Additional development notes

-- This function is still being written up.

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.

cecho2decho PR#6849 merged

convertedString = cecho2decho(str)
Converts a cecho formatted string to a decho formatted one.
See also
decho2cecho(), cecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from cecho to decho
Returns
  • a string formatted for decho
Example
-- convert to a decho string and use decho to display it
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
decho(cecho2decho(cechoString))

cecho2hecho PR#6849 merged

convertedString = cecho2hecho(str)
Converts a cecho formatted string to an hecho formatted one.
See also
hecho2cecho(), cecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from cecho to decho
Returns
  • a string formatted for hecho
Example
-- convert to an hecho string and use hecho to display it
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
hecho(cecho2hecho(cechoString))

cecho2html PR#6849 merged

convertedString = cecho2html(str[, resetFormat])
Converts a cecho formatted string to an html formatted one.
See also
decho2cecho(), cecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from cecho to decho
  • resetFormat
optional table of default formatting options. As returned by getLabelFormat()
Returns
  • a string formatted for html
Example
-- create the base string
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"

-- create a label to display the result onto
testLabel = Geyser.Label:new({name = "testLabel"})

-- convert the cecho string to an html one, using the default formatting of testLabel created above
local htmlString = cecho2html(cechoString, testLabel:getFormat())

-- and finally echo it to the label to see
-- I use rawEcho as that displays the html exactly as given.
testLabel:rawEcho(htmlString)

decho2cecho PR#6849 merged

convertedString = decho2cecho(str)
Converts a decho formatted string to a cecho formatted one.
See also
cecho2decho(), decho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from decho to cecho
Returns
  • a string formatted for cecho
Example
-- convert to a decho string and use cecho to display it
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
cecho(decho2cecho(dechoString))

decho2hecho PR#6849 merged

convertedString = decho2hecho(str)
Converts a decho formatted string to an hecho formatted one.
See also
hecho2decho(), decho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from decho to decho
Returns
  • a string formatted for hecho
Example
-- convert to an hecho string and use hecho to display it
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
hecho(decho2hecho(dechoString))

decho2html PR#6849 merged

convertedString = decho2html(str[, resetFormat])
Converts a decho formatted string to an html formatted one.
See also
cecho2decho(), decho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from decho to decho
  • resetFormat
optional table of default formatting options. As returned by getLabelFormat()
Returns
  • a string formatted for html
Example
-- create the base string
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"

-- create a label to display the result onto
testLabel = Geyser.Label:new({name = "testLabel"})

-- convert the decho string to an html one, using the default formatting of testLabel created above
local htmlString = decho2html(dechoString, testLabel:getFormat())

-- and finally echo it to the label to see
-- I use rawEcho as that displays the html exactly as given.
testLabel:rawEcho(htmlString)

deleteMultiline PR #6779 merged

ok,err = deleteMultiline([triggerDelta])
Deletes all lines between when the multiline trigger fires and when the first trigger matched. Put another way, it deletes everything since the pattern in slot 1 matched.
See also
deleteLine(), replaceLine()
Mudlet VersionAvailable in Mudlet4.18+

Note Note: This deletes all the lines since the first match of the multiline trigger matched. Do not use this if you do not want to delete ALL of those lines.

Parameters
  • [optional]triggerDelta:
The line delta from the multiline trigger it is being called from. It is best to pass this in to ensure all lines are caught. If not given it will try to guess based on the number of patterns how many lines at most it might have to delete.
Returns
  • true if the function was able to run successfully, nil+error if something went wrong.
Example
-- if this trigger has a line delta of 3, you would call
deleteMultiline(3)

-- same thing, but with error handling
local ok,err = deleteMultiline(3)
if not ok then
  cecho("\n<firebrick>I could not delete the lines because: " .. err)
end
Additional development notes

echoPopup, revised in PR #6946

echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if there is one extra hint then the first one will be used as a (maybe containing Qt rich-text markup) tool-tip for the text otherwise the remaining hints will be concatenated, one-per-line, as a tool-tip when the text is hovered over by the pointer.
Parameters
  • windowName:
(optional) name of the window as a string to echo to. Use either main or omit for the main window, or the miniconsole's or user-window's name otherwise.
  • text:
the text string to display.
  • {commands}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}.
  • {hints}:
a table of strings which will be shown on the right-click menu and as a tool-tip for the text. If the number is the same as that of the commands table then they all will be used for the right-click menu and listed (one per line) as a plain text tooltip; alternatively if there is one extra in number than the commands table the first will be used purely for the tool tip and the remainder will be used for the right-click menu. This additional entry may be formatted as Qt style "rich-text" (in the same manner as labels elsewhere in the GUI).
  • If a particular position in the commands table is an empty string "" but there is something in the hints table then it will be listed in the right-click menu but as it does not do anything it will be shown greyed-out i.e. disabled and will not be clickable.
  • If a particular position in both the commands and the hints table are empty strings "" then this item will show as a separator (usually as a horizontal-line) in the right-click menu and it will not be clickable/do anything.
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if true or the link default (blue underline) if false, if omitted the default format is used.
Example
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})

-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})

-- one can also provide helpful information

-- todo: an example with rich-text in the tool-tips(s) - not complete yet!
echoPopup("Fancy popup", {[[echo("Doing command 1 (default one)")]], "", "", [[echo("Doing command 3")]], [[echo("Doing another command (number 4)"]], [[echo("Doing another command (number 5)"]])}, {"<p>This tooltip has HTML type tags in/around it, and it will get word-wrapped automatically to fit into a reasonable rectangle.</p><p><b>Plus</b> it can have those HTML like <i>effects</i> and be easily formatted into more than one paragraph and with <span style=\"color:cyan\">bits</span> in <span style=\"color:lime\">different</span> colors!</p><p>This example also demonstrates how to produce disabled menu (right-click) items, how to insert separators and how it now will handle multiple items with the same hint (prior to PR 6945 such duplicates will all run the command associated with the last one!) If the first command/function is an empty string then clicking on the text will have no effect, but hovering the mouse over the text will still produce the tooltip, this could be useful to display extra information about the text without doing anything by default.</p>", "Command 1 (default)", "", "Command 2 (disabled)", "Command 3", "Another command", "Another command"}, true)
echo(" remaining text.\n")

hecho2cecho PR#6849 merged

convertedString = hecho2cecho(str)
Converts a hecho formatted string to a cecho formatted one.
See also
cecho2decho(), hecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from hecho to cecho
Returns
  • a string formatted for cecho
Example
-- convert to a hecho string and use cecho to display it
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
cecho(hecho2cecho(hechoString))

hecho2decho PR#6849 merged

convertedString = hecho2decho(str)
Converts a hecho formatted string to a decho formatted one.
See also
decho2hecho(), hecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from hecho to decho
Returns
  • a string formatted for decho
Example
-- convert to a decho string and use decho to display it
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
decho(hecho2decho(hechoString))

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.

Mud Client Media Protocol

All GMCP functions to send sound and music events. For an overview on how all of these functions tie in together, see our MUD Client Media Protocol scripting overview.

Supported Protocols

Events

New or revised events that Mudlet can raise to inform a profile about changes. See Mudlet-raised events for the existing ones.

sysMapAreaChanged, PR #6615

Raised when the area being viewed in the mapper is changed, either by the player-room being set to a new area or the user selecting a different area in the area selection combo-box in the mapper controls area. Returns two additional arguments being the areaID of the area being switched to and then the one for the area that is being left.

Mudlet VersionAvailable in Mudlet ?.??+

Note Note: pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615

sysMapWindowMousePressEvent, PR #6962

Raised when the mouse is left-clicked on the mapper window.

Mudlet VersionAvailable in Mudlet ?.??+

Note Note: pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962

sysWindowOverflowEvent, PR #6872

Raised when the content in a mini-console/user window that has been set to be non-scrolling (see: enableScrolling(...) and disableScrolling(...)) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.

Mudlet VersionAvailable in Mudlet ?.??+

Note Note: pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6872 and https://github.com/Mudlet/Mudlet/pull/6848 for the Lua API functions (that also need documenting).