Difference between revisions of "Area 51"

From Mudlet
Jump to navigation Jump to search
 
(31 intermediate revisions by 3 users not shown)
Line 29: Line 29:
 
: A collection of functions that manipulate the mapper and its related features.
 
: A collection of functions that manipulate the mapper and its related features.
  
==mapSymbolFontInfo, PR #4038 closed==
+
==addRoom PR #7184 merged==
;mapSymbolFontInfo()
+
;addRoom(roomID, areaID)
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]
+
 
 +
:Creates a new room with the given room ID and area ID, returns true if the room was successfully created.
  
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
+
;Parameters
 +
* ''roomID:''
 +
: Room ID to set the room as, manually assigned or from [[#createRoomID|createRoomID()]].
 +
* ''areaID:''
 +
: Area ID to set the room in, as returned by [[#getAreaTable|getAreaTable()]] or equivalents.
  
;returns
+
{{note}} If you're not using incremental room IDs but room IDs stitched together from other factors or in-game hashes for room IDs - and your room IDs are starting off at 250+million numbers, you need to look into incrementally creating Mudlets room IDs with [[#createRoomID|createRoomID()]] and associating your room IDs with Mudlets via [[#setRoomIDbyHash|setRoomIDbyHash()]] and [[#getRoomIDbyHash|getRoomIDbyHash()]]. The reason being is that Mudlet's A* pathfinding implementation from boost cannot deal with extremely large room IDs because the resulting matrices it creates for pathfinding are enormously huge.
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:
+
{{note}} Creating your own mapping script? Check out more [[Manual:Mapper#Making_your_own_mapping_script|information here]].
:* ''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).
+
: See also: [[#createRoomID|createRoomID()]]
  
==moveMapLabel, PR #6014 open==
+
;Example:
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
+
<syntaxhighlight lang="lua">
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).
+
local newroomid = createRoomID()
 +
addRoom(newroomid)
 +
</syntaxhighlight>
  
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].
+
==getAreaRooms1, PR #7520 open==
 +
;getAreaRooms1(area id)
  
{{MudletVersion| ?.??}}
+
:Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or ''nil'' if no such area exists. Indexing starts at 1.
  
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014
+
See also: [[#getAreaRooms|getAreaRooms()]]
  
;Parameters
+
==setRoomArea PR #7184 merged====
* ''areaID/Name:''
+
;setRoomArea(roomID, newAreaID or newAreaName)
: Area ID as number or AreaName as string containing the map label.
 
  
* ''labelID/Text:''
+
:Assigns the given room (or set of rooms) to a new or different area. If the area is displayed in the mapper this will have the room be visually moved into the area as well.
: 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.
+
:roomID can also be a table of rooms for bulk assigning
  
* ''coordX/deltaX:''
+
: See also: [[#resetRoomArea|resetRoomArea()]]
: 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:''
+
;Example:
: 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.
+
<syntaxhighlight lang="lua">
 +
local newroomid = createRoomID()
 +
setRoomArea(newroomid, "My New Area")
 +
</syntaxhighlight>
 +
 
 +
<syntaxhighlight lang="lua">
 +
local rooms = { 1234, 4321, 5678 }
 +
setRoomArea(rooms, "My New Area")
 +
</syntaxhighlight>
  
* ''coordZ/deltaZ:''
+
==updateMap==
: (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.
+
;updateMap()
  
* ''absoluteNotRelativeMove:''
+
: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.
: (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
+
: See also: [[#centerview|centerview()]]
: ''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">
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
+
-- delete a some room
moveMapLabel(0, 2, 3.0, 4.0)
+
deleteRoom(500)
 +
-- now make the map show that it's gone
 +
updateMap()
 +
</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)
 
  
-- 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**:
+
==mapSymbolFontInfo, PR #4038 closed==
moveRoom(1, 2, -3.5, -2.0, true)
+
;mapSymbolFontInfo()
 +
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]
  
-- move the second label in the area with the ID number of 2, up three levels
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
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
+
;returns
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)
+
* 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.
  
-- 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:
+
::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).
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
+
==moveMapLabel, PR #6014 open==
</syntaxhighlight>
+
;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|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).
  
==moveRoom, PR #6010 open==
+
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].
;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 [[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.
 
 
 
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]
 
  
 
{{MudletVersion| ?.??}}
 
{{MudletVersion| ?.??}}
  
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014
  
 
;Parameters
 
;Parameters
* ''roomID:''
+
* ''areaID/Name:''
: Room ID number to move.
+
: 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:''
 
* ''coordX/deltaX:''
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.
+
: 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:''
 
* ''coordY/deltaY:''
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.
+
: 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:''
 
* ''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.
+
: (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:''
 
* ''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'').
+
: (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
 
;Returns
Line 130: Line 142:
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- move the first room one space to the east and two spaces to the north
+
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
moveRoom(1, 1, 2)
+
moveMapLabel(0, 2, 3.0, 4.0)
  
-- move the first room one space to the west, note the final boolean argument is unneeded
+
-- 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
moveRoom(1, -1, 0, false)
+
moveMapLabel(0, 2, -1.0, 0.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**:
+
-- 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, -3, -2, true)
+
moveRoom(1, 2, -3.5, -2.0, true)
  
-- move the second room up three levels
+
-- move the second label in the area with the ID number of 2, up three levels
moveRoom(2, 0, 0, 3)
+
moveRoom(1, 2, 0.0, 0.0, 3.0)
  
-- move the second room one space to the west, note the last two arguments are unneeded
+
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded
moveRoom(2, -1, 0, 0, false)
+
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)
  
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:
+
-- 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(2, 0, 0, 0, true)
+
moveRoom(5, "Home", 0.0, 0.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
+
-- all of the above will return the 'true'  boolean value assuming there are the indicated labels and areas
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setupMapSymbolFont, PR #4038 closed==
+
==moveRoom, PR #6010 open==
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
+
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
:configures the font used for symbols in the (2D) map.
+
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.
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]
+
 
 +
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]
 +
 
 +
{{MudletVersion| ?.??}}
  
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010
  
 
;Parameters
 
;Parameters
* ''fontName'' one of:
+
* ''roomID:''
:* - a string that is the family name of the font to use;
+
: Room ID number to move.
:* - 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
+
* ''coordX/deltaX:''
* ''true'' on success
+
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.
* ''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=
+
* ''coordY/deltaY:''
: Miscellaneous functions.
+
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.
  
==compare, PR#7122 open==
+
* ''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.
  
; sameValue = compare(a, b)
+
* ''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'').
  
: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''
+
;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.
  
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- move the first room one space to the east and two spaces to the north
 +
moveRoom(1, 1, 2)
  
{{MudletVersion|4.18}}
+
-- move the first room one space to the west, note the final boolean argument is unneeded
 +
moveRoom(1, -1, 0, false)
  
;Parameters
+
-- 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**:
* ''a:''
+
moveRoom(1, -3, -2, true)
: The first item to compare
 
* ''b:''
 
: The second item to compare
 
  
;Returns
+
-- move the second room up three levels
* Boolean true if the items have the same value, otherwise boolean false
+
moveRoom(2, 0, 0, 3)
  
;Example
+
-- move the second room one space to the west, note the last two arguments are unneeded
<syntaxhighlight lang="lua">
+
moveRoom(2, -1, 0, 0, false)
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
 
</syntaxhighlight>
 
  
; Additional development notes
+
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:
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)
+
moveRoom(2, 0, 0, 0, true)
  
==playMusicFile, PR #7026==
+
-- all of the above will return the 'true'  boolean value assuming there are rooms with 1 and 2 as ID numbers
;playMusicFile(settings table)
+
</syntaxhighlight>
:Plays music files from the Internet or the local file system to the "media" folder of the profile for later use with [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]].
 
  
{| class="wikitable"
+
==setupMapSymbolFont, PR #4038 closed==
! Required
+
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
! Key
+
:configures the font used for symbols in the (2D) map.
! Value
+
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]
! Default
+
 
! style="text-align:left;"| Purpose
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
|- style="color: green;"
+
 
| style="text-align:center;"| Yes
+
;Parameters
| name
+
* ''fontName'' one of:
| <file name>
+
:* - a string that is the family name of the font to use;
| &nbsp;
+
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};
| style="text-align:left;"|
+
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.
* Name of the media file.
+
* ''onlyUseThisFont'' (optional) one of:
* May contain directory information (i.e. weather/lightning.wav).
+
:* - 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;
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
+
:* - 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;
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
+
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
+
* ''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.
|-
+
 
| style="text-align:center;"| No
+
;Returns
| volume
+
* ''true'' on success
| 1 to 100
+
* ''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).
| 50
+
 
| style="text-align:left;"|
+
=Miscellaneous Functions=
* Relative to the volume set on the player's client.
+
: Miscellaneous functions.
|-
+
 
| style="text-align:center;"| No
+
==compare, PR#7122 open==
| fadein
+
 
|<msec>
+
; 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''
*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.
+
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]
*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
 
| finish
 
| <msec>
 
|
 
| style="text-align:left;"|
 
*  End 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 music files when true.
 
*Restarts matching new music 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.
 
|-
 
|}
 
  
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
+
{{MudletVersion|4.18}}
  
{{Note}} on Windows and certain files are not playing? Try installing the 3rd party [https://codecguide.com/download_k-lite_codec_pack_standard.htm K-lite codec pack].
+
;Parameters
 +
* ''a:''
 +
: The first item to compare
 +
* ''b:''
 +
: The second item to compare
  
{{MudletVersion|4.15}}
+
;Returns
 +
* Boolean true if the items have the same value, otherwise boolean false
  
 
;Example
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Table Parameter Syntax ----
+
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
 +
</syntaxhighlight>
  
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
; Additional development notes
playMusicFile({
+
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)
    name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
 
})
 
  
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory
+
==createVideoPlayer, PR #6439==
---- [volume] of 75 (1 to 100)
+
;createVideoPlayer([name of userwindow], x, y, width, height)
playMusicFile({
 
    name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"
 
    , volume = 75
 
})
 
  
-- OR copy once from the local file system, and play a music file stored in the profile's media directory
+
: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.
---- [volume] of 75 (1 to 100)
 
playMusicFile({
 
    name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"
 
    , volume = 75
 
})
 
  
-- OR download once from the Internet, and play music stored in the profile's media directory
+
{{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.
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds
 
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music
 
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
 
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)
 
---- [key] reference of "rugby" for stopping this unique music later
 
---- [tag] reference of "ambience" to stop and music later with the same tag
 
---- [continue] playing this music if another request for the same music comes in (false restarts it)
 
---- [url] to download once from the Internet if the music does not exist in the profile's media directory
 
playMusicFile({
 
    name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
 
    , volume = nil -- nil lines are optional, no need to use
 
    , fadein = 20000
 
    , fadeout = 53000
 
    , start = 10000
 
    , finish = 110000
 
    , loops = nil -- nil lines are optional, no need to use
 
    , key = "rugby"
 
    , tag = "ambience"
 
    , continue = true
 
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
 
})
 
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----
 
  
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
{{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.
playMusicFile(
+
 
    "167124__patricia-mcmillen__rugby-club-in-spain.mp3"  -- name
+
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]]
)
 
  
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory
+
{{MudletVersion|4.??}}
---- [volume] of 75 (1 to 100)
 
playMusicFile(
 
    getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
 
    , 75 -- volume
 
)
 
  
-- OR copy once from the local file system, and play a music file stored in the profile's media directory
+
;Example
---- [volume] of 75 (1 to 100)
+
<syntaxhighlight lang="lua">
playMusicFile(
+
-- Create a 300x300 video player in the top-left corner of Mudlet
    "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
+
createVideoPlayer(0,0,300,300)
    , 75 -- volume
 
)
 
  
-- OR download once from the Internet, and play music stored in the profile's media directory
+
-- Alternative examples using Geyser.VideoPlayer
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds
+
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music
+
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
+
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)
+
  name = "GUI.VideoPlayer",
---- [key] reference of "rugby" for stopping this unique music later
+
  x = "70%", y = 0, -- edit here if you want to move it
---- [tag] reference of "ambience" to stop and music later with the same tag
+
  width = "30%", height = "50%"
---- [continue] playing this music if another request for the same music comes in (false restarts it)  
+
}, GUI.Right)
---- [url] to download once from the Internet if the music does not exist in the profile's media directory
 
playMusicFile(
 
    "167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
 
    , nil -- volume
 
    , 20000 -- fadein
 
    , 53000 -- fadeout
 
    , 10000 -- start
 
    , nil -- loops
 
    , "rugby" -- key
 
    , "ambience" -- tag
 
    , true -- continue
 
    , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url
 
    , 110000 -- finish
 
)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==playSoundFile, PR #7026==
+
==loadVideoFile, PR #6439==
;playSoundFile(settings table)
+
;loadVideoFile(settings table) or loadVideoFile(name, [url])
:Plays sound files from the Internet or the local file system to the "media" folder of the profile for later use with [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]].
+
: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.
 +
 
 +
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.
  
 
{| class="wikitable"
 
{| class="wikitable"
! Required
+
!Required
! Key
+
!Key
! Value
+
!Value
! Default
+
! style="text-align:left;" |Purpose
! style="text-align:left;"| Purpose
 
 
|- style="color: green;"
 
|- style="color: green;"
| style="text-align:center;"| Yes
+
| style="text-align:center;" |Yes
| name
+
|name
| <file name>
+
|<file name>
| &nbsp;
+
| style="text-align:left;" |
| style="text-align:left;"|
+
*Name of the media file.
* Name of the media file.
+
*May contain directory information (i.e. weather/maelstrom.mp4).
* May contain directory information (i.e. weather/lightning.wav).
+
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
+
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
+
|- style="color: blue;"
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
+
| 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.
 
|-
 
|-
| style="text-align:center;"| No
+
|}
| volume
+
 
| 1 to 100
+
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]]
| 50
+
 
| style="text-align:left;"|
+
{{MudletVersion|4.??}}
* Relative to the volume set on the player's client.
+
 
|-
+
;Example
| style="text-align:center;"| No
+
 
| fadein
+
<syntaxhighlight lang="lua">
|<msec>
+
---- Table Parameter Syntax ----
|
+
 
|
+
-- Download from the Internet
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.
+
loadVideoFile({
*Start position: Start of media.
+
    name = "TextInMotion-VideoSample-1080p.mp4"
*End position:  Start of media plus the number of milliseconds (msec) specified.
+
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
*1000 milliseconds = 1 second.
+
})
|-
+
 
| style="text-align:center;" |No
+
-- OR download from the profile
| fadeout
+
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})
|<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
 
| finish
 
| <msec>
 
|
 
| style="text-align:left;"|
 
*  Finish 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
 
| priority
 
| 1 to 100
 
|&nbsp;
 
| style="text-align:left;" |
 
*Halts the play of current or future played media files with a lower priority while this media plays.
 
|- 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.
 
|-
 
|}
 
 
 
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
 
 
 
{{Note}} on Windows and certain files are not playing? Try installing the 3rd party [https://codecguide.com/download_k-lite_codec_pack_standard.htm K-lite codec pack].
 
 
 
{{MudletVersion|4.15}}
 
 
 
;Example
 
  
 +
-- OR download from the local file system
 +
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
 +
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Table Parameter Syntax ----
+
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----
  
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
-- Download from the Internet
playSoundFile({
+
loadVideoFile(
     name = "cow.wav"
+
    "TextInMotion-VideoSample-1080p.mp4"
})
+
     , "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
)
  
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory
+
-- OR download from the profile
---- [volume] of 75 (1 to 100)
+
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")
playSoundFile({
 
    name = getMudletHomeDir().. "/cow.wav"
 
    , volume = 75
 
})
 
  
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory
+
-- OR download from the local file system
---- [volume] of 75 (1 to 100)
+
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")
playSoundFile({
 
    name = "C:/Users/Tamarindo/Documents/cow.wav"
 
    , volume = 75
 
})
 
 
 
-- OR download once from the Internet, and play a sound stored in the profile's media directory
 
---- [volume] of 75
 
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)
 
---- [key] reference of "cow" for stopping this unique sound later
 
---- [tag] reference of "animals" to stop a group of sounds later with the same tag
 
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)
 
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory
 
playSoundFile({
 
    name = "cow.wav"
 
    , volume = 75
 
    , fadein = nil -- nil lines are optional, no need to use
 
    , fadeout = nil -- nil lines are optional, no need to use
 
    , start = nil -- nil lines are optional, no need to use
 
    , finish = nil -- nil lines are optional, no need to use
 
    , loops = 2
 
    , key = "cow"
 
    , tag = "animals"
 
    , priority = 25
 
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
 
})
 
 
</syntaxhighlight>
 
</syntaxhighlight>
<syntaxhighlight lang="lua">
 
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----
 
  
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
==playVideoFile, PR #6439==
playSoundFile(
+
;playVideoFile(settings table)
    "cow.wav" -- name
+
: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>.
)
 
 
 
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory
 
---- [volume] of 75 (1 to 100)
 
playSoundFile(
 
    getMudletHomeDir().. "/cow.wav" -- name
 
    , 75 -- volume
 
)
 
 
 
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory
 
---- [volume] of 75 (1 to 100)
 
playSoundFile(
 
    "C:/Users/Tamarindo/Documents/cow.wav" -- name
 
    , 75 -- volume
 
)
 
 
 
-- OR download once from the Internet, and play a sound stored in the profile's media directory
 
---- [volume] of 75
 
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)
 
---- [key] reference of "cow" for stopping this unique sound later
 
---- [tag] reference of "animals" to stop a group of sounds later with the same tag
 
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)
 
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory
 
playSoundFile(
 
    "cow.wav" -- name
 
    , 75 -- volume
 
    , nil -- fadein
 
    , nil -- fadeout
 
    , nil -- start
 
    , 2 -- loops
 
    , "cow" -- key
 
    , "animals" -- tag
 
    , 25 -- priority
 
    , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url
 
    , nil -- finish
 
)
 
</syntaxhighlight>
 
 
 
==stopMusic, PR #7026==
 
;stopMusic(settings table)
 
:Stop all music (no filter), or music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].
 
  
 
{| class="wikitable"
 
{| class="wikitable"
! Required
+
!Required
! Key
+
!Key
! Value
+
!Value
 
!Default
 
!Default
! style="text-align:left;"| Purpose
+
! style="text-align:left;" |Purpose
|-
+
|- style="color: green;"
| style="text-align:center;"| No
+
| style="text-align:center;" |Yes
| name
+
|name
| <file name>
+
|<file name>
|
+
|&nbsp;
| style="text-align:left;"|
+
| style="text-align:left;" |
* Name of the media file.
+
*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
 
| style="text-align:center;" |No
| key
+
| volume
|<key>
+
|1 to 100
|
+
|50
 
| style="text-align:left;" |
 
| style="text-align:left;" |
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
+
*Relative to the volume set on the player's client.
*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
+
| style="text-align:center;" |No
| tag
+
|fadein
| <tag>
+
|<msec>
 
|
 
|
| style="text-align:left;"|
+
|
* Helps categorize media.
+
*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
+
| style="text-align:center;" |No
| fadeaway
+
|fadeout
| true or false
+
|<msec>
|false
+
|
| style="text-align:left;" |
+
|
* Decrease volume from the current position for a given duration, then stops the track.
+
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().
+
*Start position:  End of the media minus the number of milliseconds (msec) specified.
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.
+
*End position:  End of the media.
 +
*1000 milliseconds = 1 second.
 
|-
 
|-
| style="text-align:center;"| No
+
| style="text-align:center;" |No
| fadeout
+
|start
|  
+
|<msec>
|5000
+
| 0
 
| style="text-align:left;" |
 
| style="text-align:left;" |
* Default duration in milliseconds to decrease volume to the end of the track.
+
*Begin play at the specified position in milliseconds.
* Only used if fadeout was not defined in playMusicFile().
 
 
|-
 
|-
|}
+
| style="text-align:center;" |No
 
+
|loops
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
+
| -1, or >= 1
 
+
|1
{{MudletVersion|4.15}}
+
| style="text-align:left;" |
 
+
*Number of iterations that the media plays.
;Example
+
*A value of -1 allows the media to loop indefinitely.
 
+
|-
<syntaxhighlight lang="lua">
+
| style="text-align:center;" |No
---- Table Parameter Syntax ----
+
|key
 
+
|<key>
-- Stop all playing music files for this profile associated with the API
+
|&nbsp;
stopMusic()
+
| style="text-align:left;" |
 
+
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
-- Stop playing the rugby mp3 by name
+
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})
+
|-
 
+
| style="text-align:center;" |No
-- Stop playing the unique sound identified as "rugby"
+
|tag
stopMusic({
+
|<tag>
    name = nil  -- nil lines are optional, no need to use
+
|&nbsp;
    , key = "rugby" -- key
+
| style="text-align:left;" |
    , tag = nil  -- nil lines are optional, no need to use
+
*Helps categorize media.
})
+
|-
 
+
| style="text-align:center;" |No
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API
+
|continue
stopMusic({
+
|true or false
    fadeaway = true
+
|true
})
+
| style="text-align:left;" |
 
+
*Continues playing matching new video files when true.
-- Decrease volume for 10 seconds (or apply the duration of fadeout set in playMusicFile()) and then stop all playing music files for this profile associated with the API
+
*Restarts matching new video files when false.
stopMusic({
+
|- style="color: blue;"
    fadeaway = true
+
| style="text-align:center;" |Maybe
    , fadeout = 10000
+
|url
})
+
|<url>
 
+
|&nbsp;
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API
+
| style="text-align:left;" |
stopMusic({
+
*Resource location where the media file may be downloaded.
    key = "rugby"
+
*Only required if the file is to be downloaded remotely or for streaming from the Internet.
    , fadeaway = true
+
|- style="color: blue;"
})
+
| style="text-align:center;" |Maybe
</syntaxhighlight>
+
|stream
<syntaxhighlight lang="lua">
+
|true or false
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----
+
|false
 +
| style="text-align:left;" |
 +
*Streams files from the Internet when true.
 +
*Download files when false (default).
 +
*Used in combination with the `url` key.
 +
|-
 +
|}
  
-- Stop all playing music files for this profile associated with the API
+
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]]
stopMusic()
 
  
-- Stop playing the rugby mp3 by name
+
{{MudletVersion|4.??}}
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")
 
  
-- Stop playing the unique sound identified as "rugby"
+
;Example
stopMusic(
+
 
     nil -- name
+
<syntaxhighlight lang="lua">
     , "rugby" -- key
+
---- Table Parameter Syntax ----
     , nil -- tag
+
 
)
+
-- Stream a video file from the Internet and play it.
 +
playVideoFile({
 +
     name = "TextInMotion-VideoSample-1080p.mp4"
 +
     , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
     , stream = true
 +
})
  
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"
+
-- 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.
stopMusic(
 
    nil -- name
 
    , "rugby" -- key
 
    , nil -- tag
 
    , true -- fadeaway
 
    , 10000 -- fadeout
 
)
 
</syntaxhighlight>
 
  
==stopSounds, PR #7026==
+
playVideoFile({
;stopSounds(settings table)
+
    name = "TextInMotion-VideoSample-1080p.mp4"
:Stop all sounds (no filter), or sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].
+
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
})
  
{| class="wikitable"
+
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
! Required
+
playVideoFile({
! Key
+
    name = "TextInMotion-VideoSample-1080p.mp4"
! Value
+
})
! Default
 
! 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.
 
|-
 
| style="text-align:center;" |No
 
| priority
 
| 1 to 100
 
|
 
| style="text-align:left;" |
 
*Halts the play of current or future played media files with a matching or lower priority.
 
|-
 
| style="text-align:center;"| No
 
| fadeaway
 
| true or false
 
|false
 
| style="text-align:left;" |
 
* Decrease volume from the current position for a given duration, then stops the track.
 
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().
 
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.
 
|-
 
| style="text-align:center;"| No
 
| fadeout
 
|
 
|5000
 
| style="text-align:left;" |
 
* Default duration in milliseconds to decrease volume to the end of the track.
 
* Only used if fadeout was not defined in playSoundFile().
 
|-
 
|}
 
  
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
+
-- 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
 +
})
  
{{MudletVersion|4.15}}
+
-- 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)
;Example
+
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
 +
})
 +
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Table Parameter Syntax ----
+
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----
  
-- Stop all playing sound files for this profile associated with the API
+
-- Stream a video file from the Internet and play it.
stopSounds()
+
playVideoFile(
 
+
    "TextInMotion-VideoSample-1080p.mp4"
-- Stop playing the cow sound
+
     , nil -- volume
stopSounds({name = "cow.wav"})
+
     , nil -- fadein
 
+
     , nil -- fadeout
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50
+
     , nil -- start
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".
+
     , nil -- loops
stopSounds({
 
     name = nil -- nil lines are optional, no need to use
 
    , key = nil -- nil lines are optional, no need to use
 
    , tag = "animals"
 
    , priority = 50
 
})
 
 
 
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API
 
stopSounds({
 
    fadeaway = true
 
})
 
 
 
-- Decrease volume for 10 seconds (or apply the duration of fadeout set in playSoundFile()) and then stop all playing music files for this profile associated with the API
 
stopSounds({
 
    fadeaway = true
 
     , fadeout = 10000
 
})
 
 
 
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API
 
stopSounds({
 
    tag = "animals"
 
     , fadeaway = true
 
    , fadeout = 3000
 
})
 
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----
 
 
 
-- Stop all playing sound files for this profile associated with the API
 
stopSounds()
 
 
 
-- Stop playing the cow sound
 
stopSounds("cow.wav")
 
 
 
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50
 
---- This would not stop sounds tagged as "animals" greater than priority 50.  This is an "AND" and not an "OR".
 
stopSounds(
 
    nil -- name
 
     , nil -- key
 
     , "animals" -- tag
 
    , 50 -- priority
 
)
 
 
 
-- Decrease the volume for 7 seconds and then stop playing sounds
 
stopSounds(
 
    nil -- name
 
 
     , nil -- key
 
     , nil -- key
 
     , nil -- tag
 
     , nil -- tag
     , nil -- priority
+
     , true -- continue
     , true -- fadeaway
+
     , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
     , 7000 -- fadeout
+
     , false -- stream
 
)
 
)
</syntaxhighlight>
 
  
==createVideoPlayer, PR #6439==
+
-- 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.
;createVideoPlayer([name of userwindow], x, y, width, height)
+
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
 +
)
  
: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.
+
-- 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
 +
)
  
{{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.
+
-- 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
 +
)
  
{{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.
+
-- 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
 +
)
  
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]]
+
-- 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
{{MudletVersion|4.18}}
+
---- [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)
;Example
+
---- [key] reference of "text" for stopping this unique video later
<syntaxhighlight lang="lua">
+
---- [tag] reference of "ambience" to stop any video later with the same tag
-- Create a 300x300 video player in the top-left corner of Mudlet
+
---- [continue] playing this video if another request for the same video comes in (false restarts it)  
createVideoPlayer(0,0,300,300)
+
---- [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)  
-- Alternative examples using Geyser.VideoPlayer
+
playVideoFile(
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})
+
    "TextInMotion-VideoSample-1080p.mp4" -- name
+
    , nil -- volume
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({
+
    , 10000 -- fadein
  name = "GUI.VideoPlayer",
+
    , 15000 -- fadeout
  x = "70%", y = 0, -- edit here if you want to move it
+
    , 5000 -- start
  width = "30%", height = "50%"
+
    , nil -- loops
}, GUI.Right)
+
    , "text" -- key
 +
    , "ambience" -- tag
 +
    , true -- continue
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
 +
    , false -- stream
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==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 [[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.
 
  
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.
+
==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()]].
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 897: Line 626:
 
!Value
 
!Value
 
! style="text-align:left;" |Purpose
 
! style="text-align:left;" |Purpose
|- style="color: green;"
+
|-
| style="text-align:center;" |Yes
+
| style="text-align:center;" |No
|name
+
| name
|<file name>
+
| <file name>
 +
| style="text-align:left;" |
 +
* Name of the media file.
 +
|-
 +
| style="text-align:center;" |No
 +
|key
 +
|<key>
 
| style="text-align:left;" |
 
| style="text-align:left;" |
*Name of the media file.
+
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
*May contain directory information (i.e. weather/maelstrom.mp4).
+
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
*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="text-align:center;" |No
|- style="color: blue;"
+
|tag
| style="text-align:center;" |Maybe
+
|<tag>
|url
 
|<url>
 
 
| style="text-align:left;" |
 
| style="text-align:left;" |
*Resource location where the media file may be downloaded.
+
*Helps categorize media.
*Only required if file to load is not part of the profile or on the local file system.
 
 
|-
 
|-
 
|}
 
|}
  
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]]
+
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.18}}
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
Line 925: Line 657:
 
---- Table Parameter Syntax ----
 
---- Table Parameter Syntax ----
  
-- Download from the Internet
+
-- Stop all playing video files for this profile associated with the API
loadVideoFile({
+
stopVideos()
    name = "TextInMotion-VideoSample-1080p.mp4"
 
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 
})
 
  
-- OR download from the profile
+
-- Stop playing the text mp4 by name
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})
+
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})
  
-- OR download from the local file system
+
-- Stop playing the unique sound identified as "text"
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
+
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">
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----
+
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----
  
-- Download from the Internet
+
-- Stop all playing video files for this profile associated with the API
loadVideoFile(
+
stopVideos()
    "TextInMotion-VideoSample-1080p.mp4"
 
    , "https://d2qguwbxlx1sbt.cloudfront.net/"
 
)
 
  
-- OR download from the profile
+
-- Stop playing the text mp4 by name
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")
+
stopVideos("TextInMotion-VideoSample-1080p.mp4")
  
-- OR download from the local file system
+
-- Stop playing the unique sound identified as "text"
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")
+
stopVideos(
 +
    nil -- name
 +
    , "text" -- key
 +
    , nil -- tag
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==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>.
 
  
 +
==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|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].
 +
 +
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 +
 +
Only one custom login text has been defined initially:
 
{| class="wikitable"
 
{| class="wikitable"
!Required
+
|+Predefined custom login texts
!Key
+
|-
!Value
+
!Id!!Custom text!!Introduced in Mudlet version
!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
+
|1||"connect {character name} {password}"||TBD
| volume
+
|}
|1 to 100
+
 
|50
+
The addition of further texts would be subject to negotiation with the Mudlet Makers.
| style="text-align:left;" |
+
 
*Relative to the volume set on the player's client.
+
;Example
|-
+
<syntaxhighlight lang="lua">
| style="text-align:center;" |No
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
|fadein
+
function doLogin()
|<msec>
+
  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")
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.
+
  else
*Start position: Start of media.
+
    tempTime(2.0, [[sendCustomLoginText()]], 1)
*End position:  Start of media plus the number of milliseconds (msec) specified.
+
  end
*1000 milliseconds = 1 second.
+
end
|-
+
</syntaxhighlight>
| style="text-align:center;" |No
+
 
|fadeout
+
==sendCharacterName, PR #3952 open==
|<msec>
+
;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.
*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.
+
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.
*End position: End of the media.
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
*1000 milliseconds = 1 second.
+
 
|-
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
| style="text-align:center;" |No
+
 
|start
+
==sendCharacterPassword, PR #3952 open==
|<msec>
+
;sendCharacterPassword()
| 0
+
 
| style="text-align:left;" |
+
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.
*Begin play at the specified position in milliseconds.
+
 
|-
+
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.
| style="text-align:center;" |No
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].
|loops
+
 
| -1, or >= 1
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
|1
+
 
| style="text-align:left;" |
+
;Example
*Number of iterations that the media plays.
+
<syntaxhighlight lang="lua">
*A value of -1 allows the media to loop indefinitely.
+
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
|-
+
function doLogin()
| style="text-align:center;" |No
+
  if getCharacterName() ~= "" then
|key
+
    tempTime(2.0, [[sendCharacterName()]], 1)
|<key>
+
    tempTime(3.0, [[sendCharacterPassword()]], 1)
|&nbsp;
+
  end
| style="text-align:left;" |
+
end
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
+
</syntaxhighlight>
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
+
 
 +
==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|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
 +
 
 +
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 +
 
 +
Only one custom login text has been defined initially:
 +
{| class="wikitable"
 +
|+Predefined custom login texts
 
|-
 
|-
| style="text-align:center;" |No
+
!Id!!Custom text!!Introduced in Mudlet version
|tag
 
|<tag>
 
|&nbsp;
 
| style="text-align:left;" |
 
*Helps categorize media.
 
 
|-
 
|-
| style="text-align:center;" |No
+
|1||"connect {character name} {password}"||TBD
|continue
+
|}
|true or false
+
 
|true
+
The addition of further texts would be subject to negotiation with the Mudlet Makers.
| style="text-align:left;" |
+
 
*Continues playing matching new video files when true.
+
;Example
*Restarts matching new video files when false.
+
<syntaxhighlight lang="lua">
|- style="color: blue;"
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
| style="text-align:center;" |Maybe
+
function doLogin()
|url
+
  if getCustomLoginTextId() ~= 1 then
|<url>
+
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
|&nbsp;
+
    echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
| style="text-align:left;" |
+
  else
*Resource location where the media file may be downloaded.
+
    tempTime(2.0, [[sendCustomLoginText()]], 1)
*Only required if the file is to be downloaded remotely or for streaming from the Internet.
+
  end
|- style="color: blue;"
+
end
| style="text-align:center;" |Maybe
+
</syntaxhighlight>
|stream
+
 
|true or false
+
=Mudlet Object Functions=
|false
+
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.
| style="text-align:left;" |
+
 
*Streams files from the Internet when true.
+
==ancestors, new in PR #6726==
*Download files when false (default).
+
;ancestors(IDnumber, type)
*Used in combination with the `url` key.
+
: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
  
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]]
+
;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'.
  
{{MudletVersion|4.18}}
+
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]
  
 
;Example
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Table Parameter Syntax ----
+
-- To do
 +
</syntaxhighlight>
  
-- Stream a video file from the Internet and play it.
+
==findItems, new in PR #6742==
playVideoFile({
+
;findItems("name", "type"[, exact[, case sensitive]])
    name = "TextInMotion-VideoSample-1080p.mp4"
+
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.
    , 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.
+
: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.
  
playVideoFile({
+
;Parameters
    name = "TextInMotion-VideoSample-1080p.mp4"
+
* ''name:''
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
+
: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.
  
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
;Example
playVideoFile({
+
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:
    name = "TextInMotion-VideoSample-1080p.mp4"
+
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]
})
 
  
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
+
<syntaxhighlight lang="lua">
---- [volume] of 75 (1 to 100)
+
-- Should find just the package with the name:
playVideoFile({
+
lua findItems("echo", "alias")
    name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"
+
{ 3 }
    , volume = 75
+
 
})
+
-- Should find both the package and the alias - as the latter contains "echo" with another character
 +
lua findItems("echo", "alias", false)
 +
{ 3, 4 }
  
-- OR copy once from the local file system, and play a video file stored in the profile's media directory
+
-- Finds the ID numbers of all the aliases:
---- [volume] of 75 (1 to 100)
+
lua findItems("", "alias", false)
playVideoFile({
+
{ 1, 2, 3, 4, 5, 6, 7 }
    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
+
-- Will still find the package with the name "echo" as we are not concerned with the casing now:
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
+
lua findItems("Echo", "alias", true, false)
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
+
{ 3 }
---- [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
+
-- Won't find the package with the name "echo" now as we are concerned with the casing:
---- [tag] reference of "ambience" to stop any video later with the same tag
+
lua findItems("Echo", "alias", true, true)
---- [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>
<syntaxhighlight lang="lua">
 
---- 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.
+
==getExitStubsNames, new in PR #7519==
playVideoFile(
+
;table = getExitStubsNames(roomid)
    "TextInMotion-VideoSample-1080p.mp4"
+
 
    , nil -- volume
+
:Returns a table of directions that have an exit stub marked in them. Returns nil plus error message of called on a non-existent room.
    , nil -- fadein
+
 
    , nil -- fadeout
+
: See also: [[#setExitStub|setExitStub()]], [[#connectExitStub|connectExitStub()]], [[#getExitStubs|getExitStubs()]], [[#getExitStubs1|getExitStubs1()]]
    , nil -- start
+
 
    , nil -- loops
+
;Example
    , nil -- key
+
<syntaxhighlight lang="lua">
    , nil -- tag
+
-- show the exit stubs in room 6 as direction names
    , true -- continue
+
local directions = getExitStubsNames(6)
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
+
for i = 1, #directions do print(directions[i]) end
    , false -- stream
+
-- will return a table such as
)
+
{ "north", "south", "up", "in" }
 +
</syntaxhighlight>
 +
 
 +
==getProfiles, new in PR #7423==
 +
;getProfiles()
 +
 
 +
:Return a table containing some basic information about the game profiles available to Mudlet.  The key is the profile name and values can be <code>host</code>, <code>port</code>, <code>loaded</code>, and <code>connected</code>.
 +
 
 +
* <code>host</code> is the hostname or IP of the server
 +
* <code>port</code> is the port of the server
 +
* <code>loaded</code> means the profile is open and can be edited, true if loaded, false otherwise
 +
* <code>connected</code> means the profile is connected to the game server (ie. playing), true if connected, false or nil otherwise
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
local profiles = getProfiles()
 +
display(profiles)
  
-- 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.
+
--output
playVideoFile(
+
{
     "TextInMotion-VideoSample-1080p.mp4"
+
  ["Abandoned Realms"] = {
    , nil -- volume
+
     host = "abandonedrealms.com",
     , nil -- fadein
+
     loaded = false,
     , nil -- fadeout
+
     port = "9000"
    , nil -- start
+
  },
    , nil -- loops
+
  FieryMUD = {
     , nil -- key
+
     connected = true,
     , nil -- tag
+
     host = "fierymud.org",
     , true -- continue
+
     loaded = true,
     , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
+
     port = "4000"
    , false -- stream
+
  }
)
+
}
 +
</syntaxhighlight>
  
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
==isActive, modified by PR #6726==
playVideoFile(
+
;isActive(name/IDnumber, type[, checkAncestors])
    "TextInMotion-VideoSample-1080p.mp4"  -- name
+
:You can use this function to check if something, or somethings, are active.  
)
 
  
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
+
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.
---- [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
+
;Parameters
---- [volume] of 75 (1 to 100)
+
* ''name:''
playVideoFile(
+
: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).
    "C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name
+
* ''type:''
    , 75 -- volume
+
: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|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]
 +
 
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")
  
-- OR download once from the Internet, and play a video stored in the profile's media directory
+
-- Can also be used to check if a specific item is enabled or not.
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
+
if isActive("spellname", "trigger") > 0 then
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
+
  -- the spellname trigger is active
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
+
else
---- [key] reference of "text" for stopping this unique video later
+
  -- it is not active
---- [tag] reference of "ambience" to stop any video later with the same tag
+
end
---- [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>
  
 +
{{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.
  
==stopVideos, PR #6439==
+
==isAncestorsActive, new in PR #6726==
;stopVideos(settings table)
+
;isAncestorsActive(IDnumber, "type")
: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()]].
+
: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(...)]]).
 +
 
 +
: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.
  
{| class="wikitable"
+
;Parameters
!Required
+
* ''IDnumber:''
!Key
+
: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).
!Value
+
* ''type:''
! style="text-align:left;" |Purpose
+
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.
|-
 
| 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.
 
|-
 
|}
 
  
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]]
+
:See also: [[#exists|exists(...)]]
 
 
{{MudletVersion|4.18}}
 
  
 
;Example
 
;Example
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Table Parameter Syntax ----
+
-- To do
 +
</syntaxhighlight>
 +
 
 +
==loadProfile, new in PR #7423==
 +
;loadProfile(name, offline)
 +
:Load a profile, same as clicking the profile icon in the Profile Manager.
  
-- Stop all playing video files for this profile associated with the API
+
:Returns ''nil'' and an error message if either parameter is not valid.
stopVideos()
 
  
-- Stop playing the text mp4 by name
+
;Parameters
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})
+
* ''name:''
 +
: The profile name to open, as identified in the Profile Manager.
 +
* ''offline:''
 +
: true - load the profile but do not connect to the game, false - load the profile and connect to the game
  
-- Stop playing the unique sound identified as "text"
+
;Example
stopVideos({
+
<syntaxhighlight lang="lua">
    name = nil  -- nil lines are optional, no need to use
+
-- load and connect to the Archaea profile
    , key = "text" -- key
+
loadProfile("Archaea", false)
    , tag = nil  -- nil lines are optional, no need to use
 
})
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== clearProfileInformation(), new in PR #7511==
 +
;clearProfileInformation(text)
 +
:Clears the information text as displayed in the Profile Connection Window.  If this is a prepackaged game the text is reverted to the default text.
 +
 +
:See also: [[#getProfileInformation|getProfileInformation()]], [[#setProfileInformation|setProfileInformation()]]
 +
 +
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----
+
clearProfileInformation()
 +
</syntaxhighlight>
  
-- Stop all playing video files for this profile associated with the API
+
== getProfileInformation(), new in PR #7511==
stopVideos()
+
;getProfileInformation()
 +
:Return a string containing the information text as displayed in the Profile Connection Window.
  
-- Stop playing the text mp4 by name
+
:See also: [[#clearProfileInformation|clearProfileInformation()]], [[#setProfileInformation|setProfileInformation()]]
stopVideos("TextInMotion-VideoSample-1080p.mp4")
 
  
-- Stop playing the unique sound identified as "text"
+
;Example
stopVideos(
+
<syntaxhighlight lang="lua">
    nil -- name
+
echo(getProfileInformation())
    , "text" -- key
 
    , nil -- tag
 
)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
== setProfileInformation(), new in PR #7511==
 +
;setProfileInformation(text)
 +
:Set the information text as displayed in the Profile Connection Window.  Returns nil and an error messages if no string is supplied.
  
==getCustomLoginTextId, PR #3952 open==
+
:See also: [[#clearProfileInformation|clearProfileInformation()]], [[#getProfileInformation|getProfileInformation()]]
;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.
+
;Example
 +
<syntaxhighlight lang="lua">
 +
setProfileInformation("Elf warrior, lvl 15")
 +
</syntaxhighlight>
  
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.
+
=Networking Functions=
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].
+
:A collection of functions for managing networking.
  
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
+
==sendAll PR #7536 (merged)==
 
+
; sendAll([time delay], list of things to send, [echo back or not])
Only one custom login text has been defined initially:
+
: sends multiple things to the game with an optional delay between sends. If you'd like the commands not to be shown, include ''false'' at the end.
{| class="wikitable"
 
|+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.
+
:See also: [[Manual:Basic_Essentials#send|send()]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
+
-- instead of using many send() calls, you can use one sendAll
function doLogin()
+
sendAll("outr paint", "outr canvas", "paint canvas")
  if getCustomLoginTextId() ~= 1 then
+
-- can also have the commands not be echoed
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
+
sendAll("hi", "bye", false)
    echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
+
-- add an optional delay (in seconds, accepts decimals) which slows down the sent commands
  else
+
-- 2 second delay, then sends "hi", 2 second delay then sends "bye", 2 second delay then sends "wave")
    tempTime(2.0, [[sendCustomLoginText()]], 1)
+
sendAll(2, "hi", "bye", "wave")
  end
+
</syntaxhighlight>
end
+
 
</syntaxhighlight>
+
==sendSocket revised in PR #7066 (Open)==
  
==sendCharacterName, PR #3952 open==
+
;sendSocket(data)
;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.
+
: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 [[Manual:Supported_Protocols#Adding_support_for_a_telnet_protocol|new telnet protocol]], [http://forums.mudlet.org/viewtopic.php?f=5&t=2272 simultronics] [http://forums.mudlet.org/viewtopic.php?f=5&t=2213#p9810 login] etc.
  
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.
+
; success = sendSocket("data")
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
 
  
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
+
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]
  
==sendCharacterPassword, PR #3952 open==
+
{{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 [[Manual:Lua_Functions#feedTelnet|feedTelnet()]].
;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.
+
{{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.
  
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.
+
;Parameters
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].
+
* ''data:''
 +
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.
  
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
+
;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
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
+
-- 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!
function doLogin()
+
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
  if getCharacterName() ~= "" then
+
-- comments up top should introduce / explain what it does
    tempTime(2.0, [[sendCharacterName()]], 1)
+
 
    tempTime(3.0, [[sendCharacterPassword()]], 1)
+
local something = function(exampleValue)
  end
+
if something then
 +
  -- do something with something (assuming there is a meaningful return value)
 
end
 
end
</syntaxhighlight>
 
  
==sendCustomLoginText, PR #3952 open ==
+
-- maybe another example for the optional second case
;sendCustomLoginText()
+
local somethingElse = function(exampleValue, anotherValue)
  
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.
+
-- lastly, include an example with error handling to give an idea of good practice
 
+
local ok, err = function()
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.
+
if not ok then
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
+
  debugc(f"Error: unable to do <particular thing> because {err}\n")
 +
  return
 +
end
 +
</syntaxhighlight>
 +
 
 +
; Additional development notes
 +
-- This function is still being written up.
 +
 
 +
==feedTelnet added in PR #7066 (Open)====
 +
 
 +
; feedTelnet(data)
  
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
+
: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.
  
Only one custom login text has been defined initially:
+
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]
{| class="wikitable"
 
|+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.
+
{{MudletVersion|tbd}}
  
;Example
+
{{note}} This is not really intended for end-user's but might be useful in some circumstances.
<syntaxhighlight lang="lua">
 
-- 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
 
</syntaxhighlight>
 
  
=Mudlet Object Functions=
+
;Parameters
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.
+
* ''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.
  
==ancestors, new in PR #6726==
+
;Returns
;ancestors(IDnumber, type)
+
* 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.
: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:
+
{| class="wikitable sortable"
:* its IDnumber as a number
+
|+ Token value table
:* its name as a string
+
|-
:* whether it is active as a boolean
+
! Token !! Byte !! Version!! Notes
:* 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
+
|| <00> || \0x00 || 1 || 0 dec.
 
+
|-
;Parameters
+
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary
* ''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).
+
|| <NUL> || \0x00 || 1 || ASCII control character: NULL
* ''type:''
+
|-
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.
+
|| <01> || \x01 || 1 || 1 dec.
 
+
|-
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]
+
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo
 
+
|-
;Example
+
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading
<syntaxhighlight lang="lua">
+
|-
-- To do
+
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect
</syntaxhighlight>
+
|-
 
+
|| <STX> || \x02 || 1 || ASCII control character: Start of Text
==findItems, new in PR #6742==
+
|-
;findItems("name", "type"[, exact[, case sensitive]])
+
|| <03> || \x03 || 1 || 3 dec.
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.
+
|-
 
+
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead
: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.
+
|-
 
+
|| <ETX> || \x03 || 1 || ASCII control character: End of Text
;Parameters
+
|-
* ''name:''
+
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation
: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:''
+
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.
+
|-
* ''exact:''
+
|| <05> || \x05 || 1 ||
:(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:''
+
|| <O_STATUS> || \x05 || 1 ||
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.
+
|-
 
+
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry
;Example
+
|-
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:
+
|| <06> || \x06 || 1 || Telnet option: Timing Mark
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]
+
|-
 
+
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge
<syntaxhighlight lang="lua">
+
|-
-- Should find just the package with the name:
+
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo
lua findItems("echo", "alias")
+
|-
{ 3 }
+
|| <BELL> || \x07 || 1 || ASCII control character: Bell
 
+
|-
-- Should find both the package and the alias - as the latter contains "echo" with another character
+
|| <08> || \x08 || 1 || Telnet option: Output Line Width
lua findItems("echo", "alias", false)
+
|-
{ 3, 4 }
+
|| <BS> || \x08 || 1 ||
 
+
|-
-- Finds the ID numbers of all the aliases:
+
|| <09> || \x09 || 1 || Telnet option: Output Page Size
lua findItems("", "alias", false)
+
|-
{ 1, 2, 3, 4, 5, 6, 7 }
+
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab
 
+
|-
-- Will still find the package with the name "echo" as we are not concerned with the casing now:
+
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition
lua findItems("Echo", "alias", true, false)
+
|-
{ 3 }
+
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed
 
+
|-
-- Won't find the package with the name "echo" now as we are concerned with the casing:
+
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops
lua findItems("Echo", "alias", true, true)
+
|-
{}
+
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab
</syntaxhighlight>
+
|-
 
+
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition
==isActive, modified by PR #6726==
+
|-
;isActive(name/IDnumber, type[, checkAncestors])
+
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed
:You can use this function to check if something, or somethings, are active.
+
|-
 
+
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.
+
|-
 
+
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return
;Parameters
+
|-
* ''name:''
+
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops
: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:''
+
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').
+
|-
* ''checkAncestors:''
+
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition
:(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''').
+
|-
 
+
|| <SI> || \x0f || 1 || ASCII control character: Shift-In
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]
+
|-
 
+
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition
;Example
+
|-
<syntaxhighlight lang="lua">
+
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")
+
|-
 
+
|| <11> || \x11 || 1 || Telnet option: Extended ASCII
-- Can also be used to check if a specific item is enabled or not.
+
|-
if isActive("spellname", "trigger") > 0 then
+
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1
  -- the spellname trigger is active
+
|-
else
+
|| <12> || \x12 || 1 || Telnet option: Logout
  -- it is not active
+
|-
end
+
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2
</syntaxhighlight>
+
|-
 
+
|| <13> || \x13 || 1 || Telnet option: Byte Macro
{{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.
+
|-
 
+
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3
==isAncestorsActive, new in PR #6726==
+
|-
;isAncestorsActive(IDnumber, "type")
+
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal
: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(...)]]).
+
|-
 
+
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4
: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.
+
|-
 
+
|| <15> || \x15 || 1 || Telnet option: SUPDUP
;Parameters
+
|-
* ''IDnumber:''
+
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge
: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:''
+
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.
+
|-
 
+
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle
:See also: [[#exists|exists(...)]]
+
|-
 
+
|| <17> || \x17 || 1 || Telnet option: Send location
;Example
+
|-
<syntaxhighlight lang="lua">
+
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block
-- To do
+
|-
</syntaxhighlight>
+
|| <18> || \x18 || 1 ||
 
+
|-
=Networking Functions=
+
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type
:A collection of functions for managing networking.
+
|-
==sendSocket revised in PR #7066 (Open)==
+
|| <CAN> || \x18 || 1 || ASCII control character: Cancel
 
+
|-
;sendSocket(data)
+
|| <19> || \x19 || 1 ||
 
+
|-
: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 [[Manual:Supported_Protocols#Adding_support_for_a_telnet_protocol|new telnet protocol]], [http://forums.mudlet.org/viewtopic.php?f=5&t=2272 simultronics] [http://forums.mudlet.org/viewtopic.php?f=5&t=2213#p9810 login] etc.
+
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record
 
+
|-
; success = sendSocket("data")
+
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium
 
+
|-
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]
+
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification
 
+
|-
{{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 [[Manual:Lua_Functions#feedTelnet|feedTelnet()]].
+
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute
 
+
|-
{{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.
+
|| <1B> || \x1b || 1 || Telnet option: Output Marking
 
+
|-
;Parameters
+
|| <ESC> || \x1b || 1 || ASCII control character: Escape
* ''data:''
+
|-
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.
+
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number
 
+
|-
;Returns
+
|| <FS> || \x1c || 1 || ASCII control character: File Separator
* (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.
+
|-
 
+
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime
;Example
+
|-
<syntaxhighlight lang="lua">
+
|| <GS> || \x1d || 1 || ASCII control character: Group Separator
-- 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.
+
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD
-- comments up top should introduce / explain what it does
+
|-
 
+
|| <RS> || \x1e || 1 || ASCII control character: Record Separator
local something = function(exampleValue)
+
|-
if something then
+
|| <1F> || \x1f || 1 ||
  -- do something with something (assuming there is a meaningful return value)
+
|-
end
+
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size
 
+
|-
-- maybe another example for the optional second case
+
|| <US> || \x1f || 1 || ASCII control character: Unit Separator
local somethingElse = function(exampleValue, anotherValue)
+
|-
 
+
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space
-- lastly, include an example with error handling to give an idea of good practice
+
|-
local ok, err = function()
+
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)
if not ok then
+
|-
  debugc(f"Error: unable to do <particular thing> because {err}\n")
+
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set
  return
+
|-
end
+
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit
</syntaxhighlight>
+
|-
 
+
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol
; Additional development notes
+
|-
-- This function is still being written up.
+
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol
 
+
|-
==feedTelnet added in PR #7066 (Open)====
+
|| <O_MCCP> || \x55 || 1 || 85 dec
 
+
|-
; feedTelnet(data)
+
|| <O_MCCP2> || \x56 || 1 || 86 dec
 
+
|-
: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.
+
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol
 
+
|-
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]
+
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol
 
+
|-
{{MudletVersion|tbd}}
+
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol
 
+
|-
{{note}} This is not really intended for end-user's but might be useful in some circumstances.
+
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol
 
 
;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.
 
 
 
{| class="wikitable sortable"
 
|+ Token value table
 
 
|-
 
|-
! Token !! Byte !! Version!! Notes
+
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete
 
|-
 
|-
|| <00> || \0x00 || 1 || 0 dec.
+
|| <O_ATCP> || \xc8 || 1 || 200 dec
 
|-
 
|-
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary
+
|| <O_GMCP> || \xc9 || 1 || 201 dec
 
|-
 
|-
|| <NUL> || \0x00 || 1 || ASCII control character: NULL
+
|| <T_EOR> || \xef || 1 || 239 dec
 
|-
 
|-
|| <01> || \x01 || 1 || 1 dec.
+
|| <F0> || \xf0 || 1 ||
 
|-
 
|-
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo
+
|| <T_SE> || \xf0 || 1 ||
 
|-
 
|-
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading
+
|| <F1> || \xf1 || 1 ||
 
|-
 
|-
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect
+
|| <T_NOP> || \xf1 || 1 ||
 
|-
 
|-
|| <STX> || \x02 || 1 || ASCII control character: Start of Text
+
|| <F2> || \xf2 || 1 ||
 
|-
 
|-
|| <03> || \x03 || 1 || 3 dec.
+
|| <T_DM> || \xf2 || 1 ||
 
|-
 
|-
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead
+
|| <F3> || \xf3 || 1 ||
 
|-
 
|-
|| <ETX> || \x03 || 1 || ASCII control character: End of Text
+
|| <T_BRK> || \xf3 || 1 ||
 
|-
 
|-
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation
+
|| <F4> || \xf4 || 1 ||
 
|-
 
|-
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission
+
|| <T_IP> || \xf4 || 1 ||
 
|-
 
|-
|| <05> || \x05 || 1 ||  
+
|| <F5> || \xf5 || 1 ||
 
|-
 
|-
|| <O_STATUS> || \x05 || 1 ||
+
|| <T_ABOP> || \xf5 || 1 ||
 
|-
 
|-
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry
+
|| <F6> || \xf6 || 1 ||
 
|-
 
|-
|| <06> || \x06 || 1 || Telnet option: Timing Mark
+
|| <T_AYT> || \xf6 || 1 ||
 
|-
 
|-
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge
+
|| <F7> || \xf7 || 1 ||
 
|-
 
|-
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo
+
|| <T_EC> || \xf7 || 1 ||
 
|-
 
|-
|| <BELL> || \x07 || 1 || ASCII control character: Bell
+
|| <F8> || \xf8 || 1 ||
 
|-
 
|-
|| <08> || \x08 || 1 || Telnet option: Output Line Width
+
|| <T_EL> || \xf8 || 1 ||
 
|-
 
|-
|| <BS> || \x08 || 1 ||
+
|| <F9> || \xf9 || 1 ||
 
|-
 
|-
|| <09> || \x09 || 1 || Telnet option: Output Page Size
+
|| <T_GA> || \xf9 || 1 ||
 
|-
 
|-
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab
+
|| <FA> || \xfa || 1 ||
 
|-
 
|-
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition
+
|| <T_SB> || \xfa || 1 ||
 
|-
 
|-
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed
+
|| <FB> || \xfb || 1 ||
 
|-
 
|-
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops
+
|| <T_WILL> || \xfb || 1 ||
 
|-
 
|-
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab
+
|| <FC> || \xfc || 1 ||
 
|-
 
|-
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition
+
|| <T_WONT> || \xfc || 1 ||
 
|-
 
|-
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed
+
|| <FD> || \xfd || 1 ||
 
|-
 
|-
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition
+
|| <T_DO> || \xfd || 1 ||
 
|-
 
|-
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return
+
|| <FE> || \xfe || 1 ||
 
|-
 
|-
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops
+
|| <T_DONT> || \xfe || 1 ||
 
|-
 
|-
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out
+
|| <FF> || \xff || 1 ||
 
|-
 
|-
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition
+
|| <T_IAC> || \xff'
|-
+
|}
|| <SI> || \x0f || 1 || ASCII control character: Shift-In
+
 
|-
+
;Example
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition
+
<syntaxhighlight lang="lua">
|-
+
-- 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!
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape
+
-- 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
|| <11> || \x11 || 1 || Telnet option: Extended ASCII
+
 
|-
+
local something = feedTelnet(exampleValue)
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1
+
if something then
|-
+
  -- do something with something (assuming there is a meaningful return value)
|| <12> || \x12 || 1 || Telnet option: Logout
+
end
|-
+
 
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2
+
-- maybe another example for the optional second case
|-
+
local somethingElse = function(exampleValue, anotherValue)
|| <13> || \x13 || 1 || Telnet option: Byte Macro
+
 
|-
+
-- lastly, include an example with error handling to give an idea of good practice
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3
+
local ok, err = function()
|-
+
if not ok then
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal
+
  debugc(f"Error: unable to do <particular thing> because {err}\n")
|-
+
  return
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4
+
end
|-
+
</syntaxhighlight>
|| <15> || \x15 || 1 || Telnet option: SUPDUP
+
 
|-
+
; Additional development notes
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge
+
-- This function is still being written up.
|-
+
 
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output
+
=String Functions=
|-
+
:These functions are used to manipulate strings.
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle
+
 
|-
+
=Table Functions=
|| <17> || \x17 || 1 || Telnet option: Send location
+
: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.
|-
+
 
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block
+
=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.
|| <18> || \x18 || 1 ||
+
 
|-
+
=UI Functions=
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type
+
: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.
|-
+
 
|| <CAN> || \x18 || 1 || ASCII control character: Cancel
+
==cecho2decho PR#6849 merged==
|-
+
; convertedString = cecho2decho(str)
|| <19> || \x19 || 1 ||
+
 
|-
+
:Converts a cecho formatted string to a decho formatted one.
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record
+
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
|-
+
 
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium
+
{{MudletVersion|4.18}}
|-
+
 
|| <1A> || \x1a || 1 || Telnet option:  TACACS User Identification
+
;Parameters
|-
+
* ''str''
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute
+
: string you wish to convert from cecho to decho
|-
+
;Returns
|| <1B> || \x1b || 1 || Telnet option: Output Marking
+
* a string formatted for decho
|-
+
 
|| <ESC> || \x1b || 1 || ASCII control character: Escape
+
;Example
|-
+
<syntaxhighlight lang="lua">
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number
+
-- convert to a decho string and use decho to display it
|-
+
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
|| <FS> || \x1c || 1 || ASCII control character: File Separator
+
decho(cecho2decho(cechoString))
|-
+
</syntaxhighlight>
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime
+
 
|-
+
==cecho2hecho PR#6849 merged==
|| <GS> || \x1d || 1 || ASCII control character: Group Separator
+
; convertedString = cecho2hecho(str)
|-
+
 
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD
+
:Converts a cecho formatted string to an hecho formatted one.
|-
+
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
|| <RS> || \x1e || 1 || ASCII control character: Record Separator
+
 
|-
+
{{MudletVersion|4.18}}
|| <1F> || \x1f || 1 ||
+
 
|-
+
;Parameters
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size
+
* ''str''
|-
+
: string you wish to convert from cecho to decho
|| <US> || \x1f || 1 || ASCII control character: Unit Separator
+
;Returns
|-
+
* a string formatted for hecho
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space
+
 
|-
+
;Example
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)
+
<syntaxhighlight lang="lua">
|-
+
-- convert to an hecho string and use hecho to display it
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set
+
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
|-
+
hecho(cecho2hecho(cechoString))
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit
+
</syntaxhighlight>
|-
+
 
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol
+
==cecho2html PR#6849 merged==
|-
+
; convertedString = cecho2html(str[, resetFormat])
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol
+
 
|-
+
:Converts a cecho formatted string to an html formatted one.  
|| <O_MCCP> || \x55 || 1 || 85 dec
+
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]
|-
+
 
|| <O_MCCP2> || \x56 || 1 || 86 dec
+
{{MudletVersion|4.18}}
|-
+
 
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol
+
;Parameters
|-
+
* ''str''
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol
+
: string you wish to convert from cecho to decho
|-
+
* ''resetFormat''
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol
+
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
|-
+
;Returns
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol
+
* a string formatted for html
|-
+
 
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete
+
;Example
|-
+
<syntaxhighlight lang="lua">
|| <O_ATCP> || \xc8 || 1 || 200 dec
+
-- create the base string
|-
+
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
|| <O_GMCP> || \xc9 || 1 || 201 dec
+
 
|-
+
-- create a label to display the result onto
|| <T_EOR> || \xef || 1 || 239 dec
+
testLabel = Geyser.Label:new({name = "testLabel"})
|-
+
 
|| <F0> || \xf0 || 1 ||
+
-- convert the cecho string to an html one, using the default formatting of testLabel created above
|-
+
local htmlString = cecho2html(cechoString, testLabel:getFormat())
|| <T_SE> || \xf0 || 1 ||
+
 
|-
+
-- and finally echo it to the label to see
|| <F1> || \xf1 || 1 ||
+
-- I use rawEcho as that displays the html exactly as given.
|-
+
testLabel:rawEcho(htmlString)
|| <T_NOP> || \xf1 || 1 ||
+
</syntaxhighlight>
|-
+
 
|| <F2> || \xf2 || 1 ||
+
==decho2cecho PR#6849 merged==
|-
+
; convertedString = decho2cecho(str)
|| <T_DM> || \xf2 || 1 ||
+
 
|-
+
:Converts a decho formatted string to a cecho formatted one.
|| <F3> || \xf3 || 1 ||
+
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
|-
+
 
|| <T_BRK> || \xf3 || 1 ||
+
{{MudletVersion|4.18}}
|-
+
 
|| <F4> || \xf4 || 1 ||
+
;Parameters
|-
+
* ''str''
|| <T_IP> || \xf4 || 1 ||
+
: string you wish to convert from decho to cecho
|-
+
;Returns
|| <F5> || \xf5 || 1 ||
+
* a string formatted for cecho
|-
+
 
|| <T_ABOP> || \xf5 || 1 ||
+
;Example
|-
+
<syntaxhighlight lang="lua">
|| <F6> || \xf6 || 1 ||
+
-- convert to a decho string and use cecho to display it
|-
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
|| <T_AYT> || \xf6 || 1 ||
+
cecho(decho2cecho(dechoString))
|-
+
</syntaxhighlight>
|| <F7> || \xf7 || 1 ||
+
 
|-
+
==decho2hecho PR#6849 merged==
|| <T_EC> || \xf7 || 1 ||
+
; convertedString = decho2hecho(str)
|-
+
 
|| <F8> || \xf8 || 1 ||
+
:Converts a decho formatted string to an hecho formatted one.
|-
+
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
|| <T_EL> || \xf8 || 1 ||
+
 
|-
+
{{MudletVersion|4.18}}
|| <F9> || \xf9 || 1 ||
+
 
|-
+
;Parameters
|| <T_GA> || \xf9 || 1 ||
+
* ''str''
|-
+
: string you wish to convert from decho to decho
|| <FA> || \xfa || 1 ||
+
;Returns
|-
+
* a string formatted for hecho
|| <T_SB> || \xfa || 1 ||
+
 
|-
+
;Example
|| <FB> || \xfb || 1 ||
+
<syntaxhighlight lang="lua">
|-
+
-- convert to an hecho string and use hecho to display it
|| <T_WILL> || \xfb || 1 ||
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
|-
+
hecho(decho2hecho(dechoString))
|| <FC> || \xfc || 1 ||
+
</syntaxhighlight>
|-
+
 
|| <T_WONT> || \xfc || 1 ||
+
==decho2html PR#6849 merged==
|-
+
; convertedString = decho2html(str[, resetFormat])
|| <FD> || \xfd || 1 ||
+
 
|-
+
:Converts a decho formatted string to an html formatted one.
|| <T_DO> || \xfd || 1 ||
+
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
|-
+
 
|| <FE> || \xfe || 1 ||
+
{{MudletVersion|4.18}}
|-
+
 
|| <T_DONT> || \xfe || 1 ||
+
;Parameters
|-
+
* ''str''
|| <FF> || \xff || 1 ||
+
: string you wish to convert from decho to decho
|-
+
* ''resetFormat''
|| <T_IAC> || \xff'
+
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
|}
+
;Returns
 +
* a string formatted for html
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- 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!
+
-- create the base string
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
-- comments up top should introduce / explain what it does
 
  
local something = feedTelnet(exampleValue)
+
-- create a label to display the result onto
if something then
+
testLabel = Geyser.Label:new({name = "testLabel"})
  -- do something with something (assuming there is a meaningful return value)
 
end
 
  
-- maybe another example for the optional second case
+
-- convert the decho string to an html one, using the default formatting of testLabel created above
local somethingElse = function(exampleValue, anotherValue)
+
local htmlString = decho2html(dechoString, testLabel:getFormat())
  
-- lastly, include an example with error handling to give an idea of good practice
+
-- and finally echo it to the label to see
local ok, err = function()
+
-- I use rawEcho as that displays the html exactly as given.
if not ok then
+
testLabel:rawEcho(htmlString)
  debugc(f"Error: unable to do <particular thing> because {err}\n")
 
  return
 
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
; Additional development notes
+
==deleteMultiline PR #6779 merged==
-- This function is still being written up.
 
  
=String Functions=
+
; ok,err = deleteMultiline([triggerDelta])
:These functions are used to manipulate strings.
 
  
=Table Functions=
+
: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.
: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.
+
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]
  
=Text to Speech Functions=
+
{{MudletVersion|4.18}}
: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=
+
{{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.
: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==
+
;Parameters
; convertedString = cecho2decho(str)
+
* ''[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.
  
: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  
 
;Returns  
* a string formatted for decho
+
* true if the function was able to run successfully, nil+error if something went wrong.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- convert to a decho string and use decho to display it
+
-- if this trigger has a line delta of 3, you would call
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
+
deleteMultiline(3)
decho(cecho2decho(cechoString))
 
</syntaxhighlight>
 
  
==cecho2hecho PR#6849 merged==
+
-- same thing, but with error handling
; convertedString = cecho2hecho(str)
+
local ok,err = deleteMultiline(3)
 +
if not ok then
 +
  cecho("\n<firebrick>I could not delete the lines because: " .. err)
 +
end
 +
</syntaxhighlight>
  
:Converts a cecho formatted string to an hecho formatted one.
+
; Additional development notes
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
 
  
{{MudletVersion|4.18}}
+
==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
+
; Parameters
* ''str''
+
* ''windowName:''
: string you wish to convert from cecho to decho
+
: (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.
;Returns
+
* ''text:''
* a string formatted for hecho
+
: the text string to display.
 
+
* ''{commands}:''
;Example
+
: 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>.
<syntaxhighlight lang="lua">
+
* ''{hints}:''
-- convert to an hecho string and use hecho to display it
+
: 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).
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
+
::* 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.
hecho(cecho2hecho(cechoString))
+
::* 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.
</syntaxhighlight>
+
* ''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"})
  
==cecho2html PR#6849 merged==
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
; convertedString = cecho2html(str[, resetFormat])
+
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
  
:Converts a cecho formatted string to an html formatted one.
+
-- one can also provide helpful information
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]
 
  
{{MudletVersion|4.18}}
+
-- 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")
  
;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>
 
</syntaxhighlight>
  
==decho2cecho PR#6849 merged==
+
==hecho2cecho PR#6849 merged==
; convertedString = decho2cecho(str)
+
; convertedString = hecho2cecho(str)
  
:Converts a decho formatted string to a cecho formatted one.  
+
:Converts a hecho formatted string to a cecho formatted one.  
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
+
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
 
{{MudletVersion|4.18}}
 
{{MudletVersion|4.18}}
Line 1,921: Line 1,593:
 
;Parameters
 
;Parameters
 
* ''str''
 
* ''str''
: string you wish to convert from decho to cecho
+
: string you wish to convert from hecho to cecho
 
;Returns  
 
;Returns  
 
* a string formatted for cecho
 
* a string formatted for cecho
Line 1,927: Line 1,599:
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- convert to a decho string and use cecho to display it
+
-- convert to a hecho string and use cecho to display it
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
cecho(decho2cecho(dechoString))
+
cecho(hecho2cecho(hechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==decho2hecho PR#6849 merged==
+
==hecho2decho PR#6849 merged==
; convertedString = decho2hecho(str)
+
; convertedString = hecho2decho(str)
  
:Converts a decho formatted string to an hecho formatted one.  
+
:Converts a hecho formatted string to a decho formatted one.  
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
+
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
 
{{MudletVersion|4.18}}
 
{{MudletVersion|4.18}}
Line 1,942: Line 1,614:
 
;Parameters
 
;Parameters
 
* ''str''
 
* ''str''
: string you wish to convert from decho to decho
+
: string you wish to convert from hecho to decho
 
;Returns  
 
;Returns  
* a string formatted for hecho
+
* a string formatted for decho
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- convert to an hecho string and use hecho to display it
+
-- convert to a decho string and use decho to display it
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
hecho(decho2hecho(dechoString))
+
decho(hecho2decho(hechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==decho2html PR#6849 merged==
+
==hecho2html PR#6849 merged==
; convertedString = decho2html(str[, resetFormat])
+
; convertedString = hecho2html(str[, resetFormat])
  
:Converts a decho formatted string to an html formatted one.  
+
:Converts a hecho formatted string to an html formatted one.  
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
+
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
 
{{MudletVersion|4.18}}
 
{{MudletVersion|4.18}}
Line 1,963: Line 1,635:
 
;Parameters
 
;Parameters
 
* ''str''
 
* ''str''
: string you wish to convert from decho to decho
+
: string you wish to convert from hecho to hecho
 
* ''resetFormat''
 
* ''resetFormat''
 
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
Line 1,972: Line 1,644:
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
 
-- create the base string
 
-- create the base string
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
  
 
-- create a label to display the result onto
 
-- create a label to display the result onto
 
testLabel = Geyser.Label:new({name = "testLabel"})
 
testLabel = Geyser.Label:new({name = "testLabel"})
  
-- convert the decho string to an html one, using the default formatting of testLabel created above
+
-- convert the hecho string to an html one, using the default formatting of testLabel created above
local htmlString = decho2html(dechoString, testLabel:getFormat())
+
local htmlString = hecho2html(hechoString, testLabel:getFormat())
  
 
-- and finally echo it to the label to see
 
-- and finally echo it to the label to see
Line 1,985: Line 1,657:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==deleteMultiline PR #6779 merged==
+
==insertPopup, revised in PR #6925==
 +
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, 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 a tool-tips table is not provided the same hints will also be listed one-per-line as a tool-tip but if a matching number of tool-tips are provided they will be concatenated to provide a tool-tip when the text is hovered over by the pointer - these tool-tips can be ''rich-text'' to produce information formatted with additional content in the same manner as labels.
  
; ok,err = deleteMultiline([triggerDelta])
+
; 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 popup if no {tool-tips} table is provided). If a particular position in both the commands and hints table are both the empty string ''""'' but there is something in the tool-tips table, no entry for that position will be made in the context menu but the tool-tip can still display something which can include images or text.
 +
* ''{tool-tips}:''
 +
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided.
 +
* ''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.
  
: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.
+
{{note}} Mudlet will distinguish between the optional tool-tips and the flag to switch between the standard link and the current text format by examining the type of the argument, as such this pair of arguments can be in either order.
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]
 
  
{{MudletVersion|4.18}}
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
 +
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
  
{{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.
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
 +
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
  
;Parameters
+
-- one can also provide helpful information
* ''[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
+
-- todo: an example with rich-text in the tool-tips(s)
* 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>
 
</syntaxhighlight>
  
; Additional development notes
+
=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]].
==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>
 
 
 
==hecho2html PR#6849 merged==
 
; convertedString = hecho2html(str[, resetFormat])
 
 
 
:Converts a hecho formatted string to an html formatted one.
 
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
 
 
 
{{MudletVersion|4.18}}
 
 
 
;Parameters
 
* ''str''
 
: string you wish to convert from hecho to hecho
 
* ''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 hechoString = "#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 hecho string to an html one, using the default formatting of testLabel created above
 
local htmlString = hecho2html(hechoString, 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>
 
 
 
==insertPopup, revised in PR #6925==
 
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, 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 a tool-tips table is not provided the same hints will also be listed one-per-line as a tool-tip but if a matching number of tool-tips are provided they will be concatenated to provide a tool-tip when the text is hovered over by the pointer - these tool-tips can be ''rich-text'' to produce information formatted with additional content in the same manner as labels.
 
 
 
; 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 popup if no {tool-tips} table is provided). If a particular position in both the commands and hints table are both the empty string ''""'' but there is something in the tool-tips table, no entry for that position will be made in the context menu but the tool-tip can still display something which can include images or text.
 
* ''{tool-tips}:''
 
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided.
 
* ''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.
 
 
 
{{note}} Mudlet will distinguish between the optional tool-tips and the flag to switch between the standard link and the current text format by examining the type of the argument, as such this pair of arguments can be in either order.
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
 
insertPopup("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)
 
insertPopup("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)
 
 
 
</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]].
 
 
 
==Playing Media, PR #7026==
 
 
 
===Playing Media===
 
 
 
Send '''Client.Media.Play''' GMCP events to play sound or music files.
 
 
 
{| class="wikitable"
 
! Required
 
! Key
 
! 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/lightning.wav).
 
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
 
|- 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 and a url was not set above with Client.Media.Default or Client.Media.Load.
 
|-
 
| style="text-align:center;"| No
 
| "type"
 
| "sound" or "music"
 
| "sound"
 
| style="text-align:left;"|
 
* Identifies the type of media.
 
|-
 
| style="text-align:center;"| No
 
| "tag"
 
| <tag>
 
| &nbsp;
 
| style="text-align:left;"|
 
* Helps categorize media.
 
|-
 
| 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.
 
* 1000 milliseconds = 1 second.
 
|-
 
| style="text-align:center;"| No
 
| "finish"
 
| <msec>
 
| 0
 
| style="text-align:left;"|
 
* End play at the specified position in milliseconds.
 
* 1000 milliseconds = 1 second.
 
|-
 
| 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 sound or music to loop indefinitely.
 
|-
 
| style="text-align:center;" |No
 
|"priority"
 
|1 to 100
 
|&nbsp;
 
| style="text-align:left;" |
 
*Halts the play of current or future played media files with a lower priority while this media plays.
 
|-
 
| style="text-align:center;" |No
 
|"continue"
 
| true or false
 
|true
 
| style="text-align:left;" |
 
*Only valid for media files with a "type" of "music".
 
*Continues playing matching new music files when true.
 
*Restarts matching new music files when false.
 
|-
 
| 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.
 
|-
 
|}
 
 
 
==== name====
 
 
 
For example, to simply play the sound of a cow mooing already stored in the "media" folder:
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "cow.wav"
 
}
 
</syntaxhighlight>
 
 
 
Or some lightning stored in a "weather" sub-folder under the "media" folder.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "weather/lightning.wav"
 
}
 
</syntaxhighlight>
 
 
 
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.
 
 
 
====url====
 
 
 
If you maintain your sound files on the Internet and don't set a default URL with Client.Media.Default, or preload them with Client.Media.Load, include the "url" parameter:
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "cow.wav",
 
  "url": "https://www.example.com/sounds/"
 
}
 
</syntaxhighlight>
 
 
 
====type: sound====
 
 
 
Media files default to a "type" of "sound" when the "type" parameter is not specified, such as in the example above. It is good practice to specify the "type" parameter to best keep media organized within your implementation:
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "cow.wav",
 
  "type": "sound"
 
}
 
</syntaxhighlight>
 
 
 
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.
 
 
 
====tag====
 
 
 
To play the sound of a sword swooshing and categorized as "combat":
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "sword1.wav",
 
  "type": "sound",
 
  "tag": "combat"
 
}
 
</syntaxhighlight>
 
 
 
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.
 
 
 
====type: music====
 
 
 
Add background music to your environment through use of the "music" value set upon the "type" parameter:
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "river.wav",
 
  "type": "music",
 
  "tag": "environment"
 
}
 
</syntaxhighlight>
 
 
 
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.
 
 
 
====volume: 1 to 100====
 
 
 
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter.  Example values, followed by syntax examples:
 
 
 
*Maximum: 100 (recommended to use rarely)
 
*High: 75
 
*Default: 50
 
* Low: 25
 
* Minimum: 1 (recommended to use rarely)
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "river.wav",
 
  "type": "music",
 
  "tag": "environment",
 
  "volume": 75
 
}
 
</syntaxhighlight>
 
 
 
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.
 
 
 
====fadein====
 
 
 
Increase volume from the start of the media [start position, volume one] to the number in milliseconds specified with the "fadein" parameter [position start + milliseconds, volume specified with the "volume" parameter].  Example values, followed by syntax examples:
 
 
 
*1000 milliseconds (1 second)
 
*60000 milliseconds (1 minute)
 
*0 milliseconds (no fade in)
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "monty_python.mp3",
 
  "type": "music",
 
  "volume": 100,
 
  "fadein": 1000
 
}
 
</syntaxhighlight>
 
        +---------------------------+-----------------------+
 
        | Fade in 1000 milliseconds |        Normal        |
 
        +---------------------------+-----------------------+
 
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100
 
        +---------------------------+-----------------------+
 
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.
 
 
 
==== fadeout====
 
 
 
Decrease volume from a position in milliseconds subtracted from the duration of the media [position duration - milliseconds, volume specified with the "volume" parameter] to the end of the media [position duration, volume one].  Example values, followed by syntax examples:
 
 
 
*1000 milliseconds (1 second)
 
*60000 milliseconds (1 minute)
 
*0 milliseconds (no fade out)
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "the_matrix.mp3",
 
  "type": "music",
 
  "volume": 50,
 
  "fadeout": 333
 
}
 
</syntaxhighlight>
 
          +-----------------------+---------------------------+
 
          |        Normal        | Fade out 333 milliseconds |
 
          +-----------------------+---------------------------+
 
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1
 
          +-----------------------+---------------------------+
 
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.
 
 
 
==== start ====
 
 
 
Start playing a media track at the number of milliseconds specified.  Example values, followed by syntax examples:
 
 
 
*1000 milliseconds (1 second)
 
*60000 milliseconds (1 minute)
 
*0 milliseconds (start from beginning)
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "mudlet_beatboxing.mp3",
 
  "type": "music",
 
  "volume": 75,
 
  "start": 1000
 
}
 
</syntaxhighlight>
 
 
 
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.
 
 
 
==== finish ====
 
 
 
Finish playing a media track at the number of milliseconds specified.  Example values, followed by syntax examples:
 
 
 
*1000 milliseconds (1 second)
 
*60000 milliseconds (1 minute)
 
*0 milliseconds (start from beginning)
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "mudlet_beatboxing.mp3",
 
  "type": "music",
 
  "volume": 75,
 
  "finish": 35000
 
}
 
</syntaxhighlight>
 
 
 
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.
 
 
 
==== loops: -1, 1 or more ====
 
 
 
The "loops" parameter controls how many times the sound repeats and defaults to 1 if not specified. A value of -1 will loop the file indefinitely.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "clock/hour_bell.wav",
 
  "type": "sound",
 
  "loops": 3
 
}
 
 
 
Client.Media.Play {
 
  "name": "underdark.mp3",
 
  "type": "music",
 
  "tag": "environment",
 
  "loops": -1
 
}
 
</syntaxhighlight>
 
 
 
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.
 
 
 
==== priority: 1 to 100 ====
 
 
 
The "priority" parameter sets precedence for Client.Media.Play GMCP events that include a "priority" setting. The values for the "priority" parameter range between 1 and 100. Given that two Client.Media.Play GMCP events have the same priority, the media already playing will continue playing. In Mudlet, media without priority set is not included comparisons based on priority.
 
 
 
A common place to find priority implemented is with combat. In the following example, imagine a combat scenario where some sounds of sword thrusts were interrupted by a successful blocking maneuver.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "sword1.wav",
 
  "type": "sound",
 
  "tag": "combat",
 
  "loops": 3,
 
  "priority": 60
 
}
 
 
 
Client.Media.Play {
 
  "name": "block1.wav",
 
  "type": "sound",
 
  "tag": "combat",
 
  "priority": 70
 
}
 
</syntaxhighlight>
 
 
 
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.
 
 
 
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.
 
 
 
====continue: true or false (for music)====
 
 
 
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:
 
 
 
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event
 
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "city.mp3",
 
  "type": "music",
 
  "tag": "environment",
 
  "continue": true
 
}
 
</syntaxhighlight>
 
 
 
If the "continue" parameter is not specified, behavior will default to ''true'' for music.
 
 
 
Although using the boolean type is recommended, Mudlet parses "continue" values of type string ("true" and "false") into boolean (''true'' and ''false'') as needed, as not all game drivers support a boolean type.
 
 
 
==== key====
 
 
 
The "key" parameter enables media categorization, similar to the "tag" parameter, however it adds a feature of uniqueness that halts media currently playing with the same key, replacing it with the media that arrived from a new Client.Media.Play GMCP event. This update will only occur if the "name" or "url" associated with the currently playing media does not match the new media, while the key is identical.
 
 
 
In the example below, consider that a player moves from a sewer area to a village.  The "key" parameter is used to stop the previously playing ''sewer.mp3'' and start playing ''village.mp3'' within the second Client.Media.Play GMCP event.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "sewer.mp3",
 
  "type": "music",
 
  "tag": "environment",
 
  "loops": -1,
 
  "continue": true,
 
  "key": "area-music"
 
}
 
 
 
Client.Media.Play {
 
  "name": "village.mp3",
 
  "type": "music",
 
  "tag": "environment",
 
  "loops": -1,
 
  "continue": true,
 
  "key": "area-music"
 
}
 
</syntaxhighlight>
 
 
 
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.
 
 
 
{{note}} Where music is bound to change, continue or stop as a player enters a new room, consider allowing for a slight pause of 1 heart beat or tick to send the Client.Media.Play or Client.Media.Stop GMCP events. This practice reduces the number of Client.Media.Play GMCP events sent when the player travels through several rooms quickly.
 
 
 
==== randomization====
 
 
 
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.
 
 
 
Given that media files underdark.wav, underdark.mp3 and underdark_dark_elven_moshpit.mp3 were all present in the media/environment directory under the current game profile, the following Client.Media.Play GMCP event would randomly choose one of those files to play using the ''*'' wildcard.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "underdark*",
 
  "type": "music",
 
  "tag": "environment",
 
  "loops": -1,
 
  "continue": false
 
}
 
</syntaxhighlight>
 
 
 
If media files sword1.wav, sword2.wav and sword3.wav were all present in the media/combat directory under the current game profile, the following Client.Media.Play GMCP event would randomly choose one of those files to play per each loop using the ''?'' wildcard.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Play {
 
  "name": "combat/sword?.wav",
 
  "type": "sound",
 
  "tag": "combat",
 
  "loops": 3
 
}
 
</syntaxhighlight>
 
 
 
==Stopping Media, PR #7026==
 
 
 
=== Stopping Media ===
 
 
 
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.
 
 
 
{| class="wikitable"
 
!Required
 
!Key
 
!Value
 
! style="text-align:left;" |Purpose
 
|-
 
| style="text-align:center;" | No
 
| "name"
 
|<file name>
 
| style="text-align:left;" |
 
*Stops playing media by name matching the value specified.
 
|-
 
| style="text-align:center;" | No
 
|"type"
 
|"sound" or "music"
 
| style="text-align:left;" |
 
*Stops playing media by type matching the value specified.
 
|-
 
| style="text-align:center;" |No
 
| "tag"
 
|<tag>
 
| style="text-align:left;" |
 
*Stops playing media by tag matching the value specified.
 
|-
 
| style="text-align:center;" |No
 
|"priority"
 
|1 to 100
 
| style="text-align:left;" |
 
*Stops playing media with priority less than or equal to the value.
 
|-
 
| style="text-align:center;" |No
 
|"key"
 
|<key>
 
| style="text-align:left;" |
 
*Stops playing media by key matching the value specified.
 
|-
 
| style="text-align:center;"| No
 
| "fadeaway"
 
| true or false
 
| style="text-align:left;" |
 
* Decrease volume from the current position for a given duration, then stops the track.
 
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.
 
* If fadeout was not specified in Client.Media.Play, then the optional fadeout parameter from Client.Media.Stop or a default of 5000 milliseconds will be applied.
 
|-
 
| style="text-align:center;"| No
 
| "fadeout"
 
|
 
| style="text-align:left;" |
 
* Default duration in milliseconds to decrease volume to the end of the track.
 
* Only used if fadeout was not defined in Client.Media.Play.
 
|-
 
|}
 
 
 
====all====
 
 
 
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Stop {}
 
</syntaxhighlight>
 
 
 
====parameters====
 
 
 
Send any combination of the name, type, tag, priority or sound parameters and valid corresponding values to stop playing media that matches ''all'' combinations of the parameters.
 
 
 
Stop the rain.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Stop {
 
  "name": "rain.wav"
 
}
 
</syntaxhighlight>
 
 
 
Stop all media using the "type" of "sound".
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Stop {
 
  "type": "sound"
 
}
 
</syntaxhighlight>
 
 
 
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Stop {
 
  "tag": "combat",
 
  "priority": 50
 
}
 
</syntaxhighlight>
 
 
 
Stop all media categorized with the "key" of "area-music".
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Stop {
 
  "key": "area-music"
 
}
 
</syntaxhighlight>
 
 
 
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Stop {
 
  "fadeaway": true
 
}
 
</syntaxhighlight>
 
 
 
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music
 
 
 
<syntaxhighlight lang="json">
 
Client.Media.Stop {
 
  "key": "area-music",
 
  "fadeaway": true,
 
  "fadeout": 10000
 
}
 
</syntaxhighlight>
 
 
 
=Supported Protocols=
 
 
 
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.
 
 
 
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.
 
 
 
==NEW-ENVIRON, PR #7058==
 
To enhance the player experience through sharing more client-supported details, the Telnet New-Environ Option may be used to transfer client environment variables from Mudlet to game servers. Sharing supporting information on information such as encoding, terminal emulation, and accessibility options aims to improve initial player setup and increase the retention rate for new gaming community members.
 
 
 
===NEW-ENVIRON in Mudlet===
 
Mudlet supports two methods of information exchange via NEW-ENVIRON, the first via [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572]: '''Telnet New-Environ Option''' (on by default), and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''' (off by default), which shares a standardized set of client information across multiple clients.
 
 
 
====Client Environment Variable Updates====
 
Mudlet provides a user-friendly interface for managing environmental variables through its Settings menu. For certain environmental variables, manual selections made in the Settings menus can dynamically notify servers that have expressed interest in the client's environmental variables through the negotiation of the NEW-ENVIRON option. For instance, when a Mudlet user updates the data encoding for a server profile by navigating to Settings, General, and choosing a specific data encoding from the drop-down menu, this information becomes available for transmission via both the RFC (default) and MNES (requires user enabling) options.
 
 
 
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====
 
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). Some information requires a user to OPT-IN to share it with the game. Some client variables updates may be reported ad-hoc with an INFO (2) message. If there is no value for a defined variable, a VAL (1) will be sent without a value following it.
 
{| class="wikitable"
 
! Type
 
! Variable
 
! Example Values
 
!Mudlet Default
 
!OPT-IN
 
!INFO
 
! Purpose
 
!Available
 
|-
 
| VAR
 
| '''SYSTEMTYPE'''
 
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX
 
|
 
|Yes
 
|
 
| Client runs within the listed operating system.
 
|Future
 
|-
 
| VAR
 
| '''USER'''
 
| tamarindo
 
|
 
|Yes
 
|
 
| Character name defined in logon dialogue.
 
|Future
 
|-
 
| USERVAR
 
| '''256_COLORS'''
 
| 1, 0
 
|1
 
|
 
|
 
| Client supports all 256 color codes. 1 = Yes/True/ACK.
 
|4.18
 
|-
 
| USERVAR
 
| '''ANSI'''
 
| 1, 0
 
|1
 
|
 
|
 
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.
 
|4.18
 
|-
 
| USERVAR
 
| '''CHARSET'''
 
| UTF-8, ASCII
 
|
 
|
 
|Yes
 
| Encoding set in the client
 
|4.18
 
|-
 
| USERVAR
 
| '''CLIENT_NAME'''
 
| MUDLET
 
|MUDLET
 
|
 
|
 
| Name of the client.
 
|4.18
 
|-
 
| USERVAR
 
| '''CLIENT_VERSION'''
 
| 4/18, 4/17/2-DEV
 
|
 
|
 
|
 
| Version of the client.
 
|4.18
 
|-
 
| USERVAR
 
| '''FONT'''
 
| Bitstream Vera Sans Mono
 
|
 
|Yes
 
|Yes
 
| Font used in the client.
 
|Future
 
|-
 
| USERVAR
 
| '''FONT_SIZE'''
 
| 14
 
|
 
|Yes
 
|Yes
 
| Font size used in the client.
 
|Future
 
|-
 
| USERVAR
 
| '''LANGUAGE'''
 
| en_US
 
|
 
|Yes
 
|Yes
 
| Client is using this language code and country variant.
 
|Future
 
|-
 
| USERVAR
 
| '''MTTS'''
 
| 2349
 
|
 
|
 
|Yes
 
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).
 
|4.18
 
|-
 
| USERVAR
 
| '''OSC_COLOR_PALETTE'''
 
| 1, 0
 
|
 
|
 
|
 
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.
 
|4.18
 
|-
 
| USERVAR
 
| '''SCREEN_READER'''
 
| 1, 0
 
|0
 
|Yes
 
|Yes
 
| Client is using a screen reader. 1 = Yes/True/ACK.
 
|4.18
 
|-
 
| USERVAR
 
| '''TERMINAL_TYPE'''
 
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB
 
|ANSI-TRUECOLOR
 
|
 
|
 
| Terminal type of the client
 
|4.18
 
|-
 
| USERVAR
 
| '''TLS'''
 
| 1, 0
 
|
 
|
 
|
 
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.
 
|4.18
 
|-
 
| USERVAR
 
| '''TRUECOLOR'''
 
| 1, 0
 
|
 
|
 
|
 
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.
 
|4.18
 
|-
 
| USERVAR
 
| '''UTF-8'''
 
| 1, 0
 
|
 
|
 
|Yes
 
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.
 
|4.18
 
|-
 
| USERVAR
 
| '''VT100'''
 
| 1, 0
 
|0
 
|
 
|
 
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.
 
|4.18
 
|-
 
| USERVAR
 
| '''WORD_WRAP'''
 
| 100
 
|
 
|
 
|Yes
 
| Client wraps text at this value
 
|4.18
 
|-
 
|}
 
 
 
====Negotiating NEW-ENVIRON====
 
Negotiating the NEW-ENVIRON Telnet option empowers game servers to request one, multiple, or all client environment variables configured within Mudlet. The process unfolds with the game server sending a Telopt DO NEW-ENVIRON (39), prompting Mudlet to respond with a WILL NEW-ENVIRON (39). Subsequently, the game server can send SB NEW-ENVIRON (39) SEND to receive all available environment variables. Mudlet responds with SB NEW-ENVIRON (39) IS (0) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] [ .. [ VAR (0) | USERVAR (3) ] "<variable>" VAL (1) "<value>"] containing the list of environmental variables.
 
 
 
Once an environmental variable is transmitted to a server within the ongoing connection, Mudlet replies with SB NEW-ENVIRON (39) INFO (2) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] messages for select variables. Importantly, no reply from the server is required in this context. If there is a need to specify a particular list of requested environmental variables to Mudlet, the format SB NEW-ENVIRON (39) SEND < VAR (0) | USERVAR (3) > "<variable>" [ .. < VAR (0) | USERVAR (3) > "<variable>" ] can be employed.
 
 
 
Success example #1 (one environmental variable):
 
{| class="wikitable"
 
! Server
 
! Mudlet
 
|-
 
| IAC DO NEW-ENVIRON (39) IAC SE
 
| IAC WILL NEW-ENVIRON (39) IAC SE
 
|-
 
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE
 
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE
 
|-
 
|}
 
 
 
Success example #2 (all environmental variables):
 
{| class="wikitable"
 
! Server
 
! Mudlet
 
|-
 
| IAC DO NEW-ENVIRON (39) IAC SE
 
| IAC WILL NEW-ENVIRON (39) IAC SE
 
|-
 
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE
 
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''SYSTEMTYPE'' VAL (1) ''MACOS'' VAR (0) ''USER'' VAL (1) ''tamarindo'' USERVAR (3) ''256_COLORS'' VAL (1) ''1'' USERVAR (3) ''ANSI'' VAL (1) ''1'' USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' USERVAR (3) ''CLIENT_NAME'' VAL (1) ''MUDLET'' USERVAR (3) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''SCREEN_READER'' VAL (1) USERVAR (3) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' USERVAR (3) ''TLS'' VAL (1) ''1'' USERVAR (3) ''TRUECOLOR'' VAL (1) ''1'' USERVAR (3) ''UTF-8'' VAL (1) ''1'' USERVAR (3) ''VT100'' VAL (1) ''0'' USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE
 
|-
 
|
 
|''[ As updates occur in the client the following are possible... ]''
 
|-
 
|
 
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE
 
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE
 
 
 
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE
 
 
 
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE
 
 
 
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE
 
 
 
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE
 
 
 
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE
 
 
 
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE
 
|-
 
|}
 
 
 
If a Mudlet user does not want to negotiate environmental variables, they may choose the Settings, Special Options menu item in Mudlet and enable "Force NEW_ENVIRON negotiation off". The following is an example of an attempted negotiation where "Force NEW-ENVIRON negotiation off" is enabled.
 
{| class="wikitable"
 
! Server
 
! Mudlet
 
|-
 
| IAC DO NEW-ENVIRON (39) IAC SE
 
| IAC WONT NEW-ENVIRON (39) IAC SE
 
|-
 
|}
 
 
 
NEW-ENVIRON negotiation is available in Mudlet 4.18+.
 
 
 
== MNES, PR #7058 ==
 
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.
 
 
 
==== Activating MNES ====
 
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.
 
 
 
[[File:Screenshot_2024-01-01_at_1.41.06_PM.png|alt=Enable MNES is found on the Game protocols section of the General tab of Settings|614x614px]]&nbsp;
 
 
 
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====
 
MNES leverages VAR (0) to transfer up to five client environment variables. Some client variables updates may be reported ad-hoc with an INFO message. If there is no value for a defined variable, a VAL (1) will be sent without a value following it.
 
{| class="wikitable"
 
! Type
 
! Variable
 
! Example Values
 
!Mudlet Default
 
!INFO
 
! Purpose
 
|-
 
| VAR
 
| '''CHARSET'''
 
| UTF-8, ASCII
 
|
 
|Yes
 
| Encoding set in the client
 
|-
 
| VAR
 
| '''CLIENT_NAME'''
 
| MUDLET
 
|MUDLET
 
|
 
| Name of the client.
 
|-
 
| VAR
 
| '''CLIENT_VERSION'''
 
| 4/18, 4/17/2-DEV
 
|
 
|
 
| Version of the client.
 
|-
 
| VAR
 
| '''MTTS'''
 
| 2349
 
|
 
|Yes
 
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).
 
|-
 
| VAR
 
| '''TERMINAL_TYPE'''
 
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB
 
|ANSI-TRUECOLOR
 
|
 
| Terminal type of the client
 
|-
 
|}
 
  
==== Negotiating MNES ====
+
=Mud Client Media Protocol=
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 5 client environment variables  ("IPADDRESS" will not be implemented in Mudlet), it uses a VAR (0) for the SEND (1), IS (0), and INFO (2) messages, and returns a multiple client variable response in multiple IS (0) messages.
+
: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]].
{| class="wikitable"
 
! Server
 
! Mudlet
 
|-
 
| IAC DO NEW-ENVIRON (39) IAC SE
 
| IAC WILL NEW-ENVIRON (39) IAC SE
 
|-
 
| IAC SB NEW-ENVIRON (39) SEND IAC SE
 
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE
 
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE
 
  
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE
+
=Supported Protocols=
  
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE
+
=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.
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE
 
|-
 
|
 
|''[ As updates occur in the client the following are possible... ]''
 
|-
 
|
 
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE
 
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE
 
|-
 
|}
 
  
MNES negotiation is available in Mudlet 4.18+.
+
===sysSettingChanged, PR #7476===
 +
This event is raised when a Preferences or Mudlet setting has changed. The first argument contains the setting that was changed, further arguments detail the change.
  
==MTTS, PR #7036==
+
Currently implemented sysSettingChanged events are;
MUD servers frequently seek information about the capabilities of a MUD Client. Despite the availability of various methods, achieving consistency and reliability in this endeavor has proven challenging. The Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]) aims to alleviate these issues by introducing a transparent and straightforward standard for MUD Clients to communicate their terminal capabilities. This standard builds upon and formalizes [https://datatracker.ietf.org/doc/html/rfc1091 RFC 1091], which outlines the Telnet Terminal-Type Option.
 
  
===MTTS in Mudlet===
+
* "main window font" - raised when the main window/console font has changed via API or Preferences window. Returns two additional arguments, the font family and the font size. e.g. {"main window font", "Times New Roman", 12 }
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities:
 
  
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.
+
{{MudletVersion| ?.??}}
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.
 
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.
 
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.
 
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).
 
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.
 
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.
 
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.
 
 
 
==== Screen Reader Opt-In ====
 
Users can find on the Accessibility tab under the Settings menu a checkbox identified as "Advertise screen reader use via protocols supporting this notice" which when checked will notify interested game servers. This information may be used to optimize the gaming experience.
 
 
 
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]
 
  
==== Available MTTS Information ====
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/7476
Through a Telnet TERMINAL-TYPE Option negotiation, Mudlet transfers a bitvector to game servers, (i.e., <code>2349</code>) for processing.  A bitvector, also known as a bitmap, is a data structure that represents a fixed-size sequence of binary digits or bits. In a bitvector, each bit corresponds to a specific position or index in the sequence, and its value can be either 0 or 1. The MTTS bitvector represents is a set of flags and boolean values, where each bit can represent the state of a particular boolean condition or flag. For example, if the third bit is set to <code>1</code>, it indicates that the client is using UTF-8 character encoding. A <code>0</code> indicator would indicate that UTF-8 was not supported.
 
{| class="wikitable"
 
|+MTTS Bitvector
 
!Bit
 
!Property
 
!Meaning
 
|-
 
|1
 
|ANSI
 
|Client supports all common ANSI color codes.
 
|-
 
|2
 
|VT100
 
|Client supports all common VT100 codes.
 
|-
 
|4
 
|UTF-8
 
|Client is using UTF-8 character encoding.
 
|-
 
|8
 
|256 COLORS
 
|Client supports all 256 color codes.
 
|-
 
|16
 
|MOUSE TRACKING
 
|Client supports xterm mouse tracking.
 
|-
 
|32
 
|OSC COLOR PALETTE
 
|Client supports OSC and the OSC color palette.
 
|-
 
|64
 
|SCREEN READER
 
|Client is using a screen reader.
 
|-
 
|128
 
|PROXY
 
|Client is a proxy allowing different users to connect from the same IP address.
 
|-
 
|256
 
|TRUECOLOR
 
|Client supports truecolor codes using semicolon notation.
 
|-
 
|512
 
|MNES
 
|Client supports the Mud New Environment Standard for information exchange.
 
|-
 
|1024
 
|MSLP
 
|Client supports the Mud Server Link Protocol for clickable link handling.
 
|-
 
|2048
 
|TLS
 
|Client supports Transport Layer Security for data encryption.
 
|}
 
 
 
====Negotiating MTTS====
 
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine within a given connection. If the connection is reset, negotiate TTYPE again. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.
 
{| class="wikitable"
 
! Server
 
! Mudlet
 
|-
 
| IAC DO TTYPE (24) IAC SE
 
| IAC WILL TTYPE (24) IAC SE
 
|-
 
| IAC SB TTYPE (24) SEND (1) IAC SE
 
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE
 
|-
 
| IAC SB TTYPE (24) SEND (1) IAC SE
 
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE
 
|-
 
|IAC SB TTYPE (24) SEND (1) IAC SE
 
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE
 
|-
 
|IAC SB TTYPE (24) SEND (1) IAC SE
 
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE
 
|-
 
|}
 
 
 
If a Mudlet user does not want to enable Mud Terminal Type Standard, they may choose the Settings, General menu item in Mudlet and toggle off the "Enable MTTS" checkbox.
 
 
 
MTTS is available in Mudlet 4.18+.
 
 
 
=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===
 
===sysMapAreaChanged, PR #6615===

Latest revision as of 05:43, 26 November 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.

addRoom PR #7184 merged

addRoom(roomID, areaID)
Creates a new room with the given room ID and area ID, returns true if the room was successfully created.
Parameters
  • roomID:
Room ID to set the room as, manually assigned or from createRoomID().
  • areaID:
Area ID to set the room in, as returned by getAreaTable() or equivalents.

Note Note: If you're not using incremental room IDs but room IDs stitched together from other factors or in-game hashes for room IDs - and your room IDs are starting off at 250+million numbers, you need to look into incrementally creating Mudlets room IDs with createRoomID() and associating your room IDs with Mudlets via setRoomIDbyHash() and getRoomIDbyHash(). The reason being is that Mudlet's A* pathfinding implementation from boost cannot deal with extremely large room IDs because the resulting matrices it creates for pathfinding are enormously huge. Note Note: Creating your own mapping script? Check out more information here.

See also: createRoomID()
Example
local newroomid = createRoomID()
addRoom(newroomid)

getAreaRooms1, PR #7520 open

getAreaRooms1(area id)
Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or nil if no such area exists. Indexing starts at 1.

See also: getAreaRooms()

setRoomArea PR #7184 merged==

setRoomArea(roomID, newAreaID or newAreaName)
Assigns the given room (or set of rooms) to a new or different area. If the area is displayed in the mapper this will have the room be visually moved into the area as well.
roomID can also be a table of rooms for bulk assigning
See also: resetRoomArea()
Example
local newroomid = createRoomID()
setRoomArea(newroomid, "My New Area")
local rooms = { 1234, 4321, 5678 }
setRoomArea(rooms, "My New Area")

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

getExitStubsNames, new in PR #7519

table = getExitStubsNames(roomid)
Returns a table of directions that have an exit stub marked in them. Returns nil plus error message of called on a non-existent room.
See also: setExitStub(), connectExitStub(), getExitStubs(), getExitStubs1()
Example
-- show the exit stubs in room 6 as direction names
local directions = getExitStubsNames(6)
for i = 1, #directions do print(directions[i]) end
-- will return a table such as 
{ "north", "south", "up", "in" }

getProfiles, new in PR #7423

getProfiles()
Return a table containing some basic information about the game profiles available to Mudlet. The key is the profile name and values can be host, port, loaded, and connected.
  • host is the hostname or IP of the server
  • port is the port of the server
  • loaded means the profile is open and can be edited, true if loaded, false otherwise
  • connected means the profile is connected to the game server (ie. playing), true if connected, false or nil otherwise
Example
local profiles = getProfiles()
display(profiles)

--output
{
  ["Abandoned Realms"] = {
    host = "abandonedrealms.com",
    loaded = false,
    port = "9000"
  },
  FieryMUD = {
    connected = true,
    host = "fierymud.org",
    loaded = true,
    port = "4000"
  }
 }

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

loadProfile, new in PR #7423

loadProfile(name, offline)
Load a profile, same as clicking the profile icon in the Profile Manager.
Returns nil and an error message if either parameter is not valid.
Parameters
  • name:
The profile name to open, as identified in the Profile Manager.
  • offline:
true - load the profile but do not connect to the game, false - load the profile and connect to the game
Example
-- load and connect to the Archaea profile
loadProfile("Archaea", false)

clearProfileInformation(), new in PR #7511

clearProfileInformation(text)
Clears the information text as displayed in the Profile Connection Window. If this is a prepackaged game the text is reverted to the default text.
See also: getProfileInformation(), setProfileInformation()
Example
clearProfileInformation()

getProfileInformation(), new in PR #7511

getProfileInformation()
Return a string containing the information text as displayed in the Profile Connection Window.
See also: clearProfileInformation(), setProfileInformation()
Example
echo(getProfileInformation())

setProfileInformation(), new in PR #7511

setProfileInformation(text)
Set the information text as displayed in the Profile Connection Window. Returns nil and an error messages if no string is supplied.
See also: clearProfileInformation(), getProfileInformation()
Example
setProfileInformation("Elf warrior, lvl 15")

Networking Functions

A collection of functions for managing networking.

sendAll PR #7536 (merged)

sendAll([time delay], list of things to send, [echo back or not])
sends multiple things to the game with an optional delay between sends. If you'd like the commands not to be shown, include false at the end.
See also: send()
Example
-- 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)
-- add an optional delay (in seconds, accepts decimals) which slows down the sent commands
-- 2 second delay, then sends "hi", 2 second delay then sends "bye", 2 second delay then sends "wave")
sendAll(2, "hi", "bye", "wave")

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

hecho2html PR#6849 merged

convertedString = hecho2html(str[, resetFormat])
Converts a hecho formatted string to an html formatted one.
See also
cecho2hecho(), hecho2html()
Mudlet VersionAvailable in Mudlet4.18+
Parameters
  • str
string you wish to convert from hecho to hecho
  • resetFormat
optional table of default formatting options. As returned by getLabelFormat()
Returns
  • a string formatted for html
Example
-- create the base string
local hechoString = "#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 hecho string to an html one, using the default formatting of testLabel created above
local htmlString = hecho2html(hechoString, 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)

insertPopup, revised in PR #6925

insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, 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 a tool-tips table is not provided the same hints will also be listed one-per-line as a tool-tip but if a matching number of tool-tips are provided they will be concatenated to provide a tool-tip when the text is hovered over by the pointer - these tool-tips can be rich-text to produce information formatted with additional content in the same manner as labels.
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 popup if no {tool-tips} table is provided). If a particular position in both the commands and hints table are both the empty string "" but there is something in the tool-tips table, no entry for that position will be made in the context menu but the tool-tip can still display something which can include images or text.
  • {tool-tips}:
(optional) a table of possibly rich-text strings which will be shown on the popup if provided.
  • 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.

Note Note: Mudlet will distinguish between the optional tool-tips and the flag to switch between the standard link and the current text format by examining the type of the argument, as such this pair of arguments can be in either order.

Example
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
insertPopup("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)
insertPopup("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)

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.

sysSettingChanged, PR #7476

This event is raised when a Preferences or Mudlet setting has changed. The first argument contains the setting that was changed, further arguments detail the change.

Currently implemented sysSettingChanged events are;

  • "main window font" - raised when the main window/console font has changed via API or Preferences window. Returns two additional arguments, the font family and the font size. e.g. {"main window font", "Times New Roman", 12 }
Mudlet VersionAvailable in Mudlet ?.??+

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

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