https://wiki.mudlet.org/api.php?action=feedcontributions&user=Tamarindo&feedformat=atomMudlet - User contributions [en]2024-03-29T14:51:40ZUser contributionsMediaWiki 1.35.0https://wiki.mudlet.org/index.php?title=Area_51&diff=21518Area 512024-03-20T10:52:13Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defined 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| CYGWIN, WIN32, MACOS, LINUX, HURD, FREEBSD, NETBSD, OPENBSD, BSD4, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=21516Area 512024-03-20T00:11:55Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| CYGWIN, WIN32, MACOS, LINUX, HURD, FREEBSD, NETBSD, OPENBSD, BSD4, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=21515Area 512024-03-20T00:05:39Z<p>Tamarindo: /* Negotiating MTTS */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=21503Area 512024-03-03T16:13:22Z<p>Tamarindo: /* stopSounds, PR #7026 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=21502Area 512024-03-03T16:12:43Z<p>Tamarindo: /* stopMusic, PR #7026 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=21501Area 512024-03-03T16:11:52Z<p>Tamarindo: /* playSoundFile, PR #7026 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]],[[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=21500Area 512024-03-03T16:09:18Z<p>Tamarindo: /* playMusicFile, PR #7026 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]], [[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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]],[[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=21499Area 512024-03-03T16:07:22Z<p>Tamarindo: /* getPlayingMusic, PR #7167 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==compare, PR#7122 open==<br />
<br />
; sameValue = compare(a, b)<br />
<br />
: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''<br />
<br />
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''a:''<br />
: The first item to compare<br />
* ''b:''<br />
: The second item to compare<br />
<br />
;Returns <br />
* Boolean true if the items have the same value, otherwise boolean false<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
local tblA = { 255, 0, 0 }<br />
local tblB = color_table.red<br />
local same = compare(tblA, tblB)<br />
display(same)<br />
-- this will return true<br />
display(tblA == tblB)<br />
-- this will display false, as they are different tables<br />
-- even though they have the same value<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
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)<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingMusic, PR #7167==<br />
;getPlayingMusic(settings table)<br />
:List all playing music (no filter), or playing music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
|}<br />
<br />
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#getPlayingSounds|getPlayingSounds()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingMusic([name][,key][,tag]) ----<br />
<br />
-- List all playing music files for this profile associated with the API<br />
getPlayingMusic()<br />
<br />
-- List all playing music matching the rugby mp3 name<br />
getPlayingMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List all playing music matching the unique key of "rugby"<br />
getPlayingMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
==getPlayingSounds, PR #7167==<br />
;getPlayingSounds(settings table)<br />
:List all playing sounds (no filter), or playing sounds that meets a combination of filters (name, key, tag, and priority) intended to be paired with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| priority<br />
| <priority><br />
|<br />
| style="text-align:left;"|<br />
* Matches media files with equal or lower priority.<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of getPlayingSounds([name][,key][,tag][,priority]) ----<br />
<br />
-- List all playing sounds for this profile associated with the API<br />
getPlayingSounds()<br />
<br />
-- List all playing sounds matching the rugby mp3 name<br />
getPlayingSounds("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- List the playing sound matching the unique key of "rugby"<br />
getPlayingSounds(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, nil -- priority<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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#getPlayingMusic|getPlayingMusic()]], [[Manual:Miscellaneous_Functions#getPlayingSounds|getPlayingSounds()]],[[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
===sysMapWindowMousePressEvent, PR #6962===<br />
Raised when the mouse is left-clicked on the mapper window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Compiling_Mudlet&diff=21496Compiling Mudlet2024-03-02T13:14:03Z<p>Tamarindo: With boost simplified, the next line needed updated about build</p>
<hr />
<div>{{TOC right}}<br />
<br />
If you just want to use Mudlet, you can skip these steps, and use one of the already ready (pre-compiled) installers [https://www.mudlet.org/download ready for download].<br />
<br />
Otherwise, hop in for new adventure! <br />
<br />
[[File:Easy Mudlet code understanding.png|400px|none]]<br />
<br />
= Key contributing information =<br />
<br />
Clang format is used to automatically format code submissions using the [https://github.com/Mudlet/Mudlet/blob/development/src/.clang-format src/.clang-format] style. [http://doc.qt.io/qtcreator/creator-beautifier.html See here] how to enable clang-format with Qt Creator - and make sure to specify the 'File' option for the configuration style.<br />
<br />
Branches:<br />
<br />
'''development''' is the development branch where new features can go.<br />
<br />
Workflow:<br />
<br />
Fork and submit a PR with your changes ([https://guides.github.com/activities/forking/ Github tutorial]).<br />
<br />
Here is a list of package versions delivered with different Linux distros. You may want to upgrade these: <br />
https://repology.org/project/mudlet/versions<br />
<br />
= Lua & Luarocks =<br />
<br />
Mudlet includes a [https://en.wikipedia.org/wiki/Lua_(programming_language) Lua] (version 5.1) scripting system for the end-user, which you, as a reader of this Wiki, may already be aware of! If not, you might wish to (after you have got your hands on a working Mudlet) take a look at [https://wiki.mudlet.org/w/Manual:Lua_Functions Mudlet Lua API] as that is the recommended place to find out the details of all the functions that Mudlet provides on top of the core Lua functionality.<br />
<br />
Some of that ability comes from extra code that is not built-in to Lua but is in the form of external modules either in the form of script (text) files written in the Lua language itself or binary (library) files compiled from (usually but not exclusively [https://en.wikipedia.org/wiki/C_(programming_language) 'C']) source code. In order to have that functionality Mudlet makes use of several of these modules which can most readily (if not already available as "packages" for a particular Operating System) be obtained as '''rocks''' from the public [https://en.wikipedia.org/wiki/LuaRocks Luarocks] collection. Such a rock actually consists of a ''rockspec'' file that gives instructions to the Luarocks tool how to obtains the (source) code, compile it on any supported OS into the form that a Lua interpreter (including the one included in '''''each''''' running Mudlet ''profile'') can use, and where and what it will be placed and called when it has been made. After that it should be available to Lua via the ''require'' command.<br />
<br />
Anyone compiling Mudlet for themselves will find it desirable to ensure they have a usable Luarocks installation and have the ''lua-yajl'' module installed before commencing to compile Mudlet itself; this is because a Lua (version 5.1) interpreter and that module are used within the build process of making the executable code that is the Mudlet application.<br />
<br />
= Compiling =<br />
<br />
== Compiling on Ubuntu ==<br />
<br />
These instructions will get you setup compiling on Ubuntu. Need a hand? Join us on Mudlet's [https://discord.gg/BwgJpMj Discord] or [http://forums.mudlet.org/viewforum.php?f=7 forums].<br />
<br />
===Ubuntu 22.04===<br />
Following instructions will work on Ubuntu 22.04 as well as all its flavours and derivatives (such as KDE Neon, for example)<br />
Important thing is to have ''Universe'' repository enabled in your package manager. (on Ubuntu you will have all the repositories that you need already enabled by default.)<br />
<br />
'''1. necessary dependencies'''<br />
<br />
Majority of required dependencies can be obtained from repositories, and can be installed with following command:<br />
<br />
sudo apt install ubuntu-restricted-extras qtcreator build-essential git zlib1g-dev libhunspell-dev \<br />
libpcre3-dev libzip-dev libboost-dev libboost-all-dev libyajl-dev libpulse-dev libpugixml-dev \<br />
liblua5.1-0-dev lua-filesystem lua-zip lua-sql-sqlite3 luarocks ccache lua5.1 \<br />
libglu1-mesa-dev mesa-common-dev libglib2.0-dev libgstreamer1.0-dev libqt5opengl5-dev \<br />
qtmultimedia5-dev qttools5-dev qt5keychain-dev libsecret-1-dev \<br />
libqt5texttospeech5-dev qtspeech5-flite-plugin qtspeech5-speechd-plugin \<br />
qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qtmultimedia5-dev<br />
<br />
Few of required Lua modules are not available in official repositories, so they have to be installed using ''luarocks''<br />
sudo luarocks install lcf<br />
sudo luarocks install luautf8<br />
sudo luarocks install lua-yajl<br />
sudo luarocks install lrexlib-pcre<br />
<br />
'''2. obtaining the source code'''<br />
<br />
Obtain the latest in-development code with:<br />
git clone --recursive -b development https://github.com/Mudlet/Mudlet.git<br />
mkdir Mudlet/build<br />
cd Mudlet/build<br />
<br />
'''3. compiling the code'''<br />
<br />
There below are two ways to build with qmake, the first is for general use, the second is for developers:<br />
qmake ../src/mudlet.pro<br />
'''*OR*'''<br />
qmake CONFIG+=debug ../src/mudlet.pro<br />
<br />
'''Now finish compiling:'''<br />
make -j `nproc`<br />
<br />
4. '''installing compiled code'''<br />
<br />
After successful code compilation, next few commands will install resulting binaries, desktop file for menus and appropriate icon.<br />
sudo make install<br />
sudo cp ../mudlet.png /usr/share/pixmaps<br />
sudo cp ../mudlet.desktop /usr/share/applications<br />
<br />
5. '''optional additional software'''<br />
<br />
One of the major reasons for compiling Mudlet from source is the ability to unlock more features that are not enabled in official AppImage.<br />
Manual compilation will resolve the issues with sound by using system provided libraries, as well as enable more detailed theming of Mudlet application itself.<br />
However, do take note that Mudlet is a Qt based program, and that theming will not 'just work' in GTK based desktop environments (Gnome, XFCE, MATE, Budgie).<br />
sudo apt install qt5ct<br />
will install a tool for configuration of look and feel of Qt programs inside those desktop environments.<br />
Users of Qt based Desktop environments (KDE Plasma, LXQT) can simply use settings provided by environment itself.<br />
<br />
Many of Qt widget styles and color schemes are available in official repositories, and will make Mudlet better.<br />
<br />
6. '''Mudlet on Wayland'''<br />
<br />
Mudlet compiled like this will run and work on Wayland, however, there are a few quirks with Keybidings (Numpad may not work as expected).<br />
Until that is resolved you may wish to start mudlet with:<br />
QT_QPA_PLATFORM=xcb mudlet<br />
(enter in terminal or simply change the Exec= line in /usr/share/applications/mudlet.desktop)<br />
<br />
7. '''uninstallation'''<br />
<br />
You can reverse the process described in this guide with following command:<br />
<br />
sudo rm -fr /usr/bin/mudlet /usr/share/mudlet /usr/share/applications/mudlet.desktop /usr/share/pixmaps/mudlet.png<br />
<br />
===Other Ubuntu Versions===<br />
<br />
Most of the installation instructions for 22.04 should work for older versions as well. Of note is the required version of Qt, which is 5.14. If your used version of Ubuntu only supplies older<br />
Qt versions, have a look at [https://launchpad.net/~beineri Stephan Binners PPAs], which supplies a whole range of packages for different Ubuntu versions. Be sure to read the installation and<br />
usage instructions as Qt is installed to /opt and requires sourcing a script to set up.<br />
<br />
== Compiling on Chrome OS ==<br />
<br />
These instructions will get you setup compiling on Chrome OS. Need a hand? Join us on Mudlet's [https://discord.gg/BwgJpMj Discord] or [http://forums.mudlet.org/viewforum.php?f=7 forums].<br />
<br />
'''1. Install dependencies'''<br />
<br />
sudo apt install git build-essential qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools \<br />
qtmultimedia5-dev qttools5-dev \<br />
lua5.1 liblua5.1-0-dev libpcre3-dev libboost-dev zlib1g-dev cmake \<br />
libhunspell-dev lua-rex-pcre2 lua-sql-sqlite3 lua-filesystem lua-zip libyajl-dev \<br />
libzip-dev libglu1-mesa-dev ccache libpugixml-dev mesa-common-dev qtcreator \<br />
libpulse-dev libglib2.0-dev luarocks libboost-all-dev libsecret-1-dev \<br />
ninja-build libsecret-1-dev<br />
sudo luarocks install luautf8<br />
sudo luarocks install lua-yajl<br />
<br />
'''3. Get Mudlet source'''<br />
<br />
git clone --recursive https://github.com/Mudlet/Mudlet.git mudlet<br />
<br />
'''4. Create a build directory'''<br />
<br />
cd mudlet<br />
mkdir build && cd build<br />
<br />
'''5. Run the following command '''<br />
<br />
cmake .. -G Ninja<br />
<br />
'''then:'''<br />
<br />
ninja<br />
<br />
'''5. Start the application you have just compiled - enjoy'''<br />
<br />
src/mudlet<br />
{{Note}}Did <code>ninja</code> fail with <code>c++: fatal error: Killed signal terminated program cclplus</code>? Try again with <code>ninja -j 2</code><br />
<br />
== Compiling on macOS ==<br />
<br />
These instructions will get you setup compiling on macOS. Need a hand? Join us on Mudlet's [https://discord.gg/BwgJpMj Discord server] or [http://forums.mudlet.org/viewforum.php?f=7 forums] otherwise.<br />
<br />
<br />
'''1. Install prerequisites'''<br />
<br />
Install [https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12 XCode], command line tools for XCode, and [http://brew.sh HomeBrew].<br />
<br />
Once everything is installed, do:<br />
<br />
brew doctor<br />
brew update<br />
brew install git<br />
<br />
'''2. Get Mudlet source'''<br />
git clone --recursive https://github.com/Mudlet/Mudlet.git <br />
<br />
'''3. Go to the parent of the mudlet "src" folder and create (if necessary) a build subdirectory (this is so that we can build out of source which keeps the source code clean)'''<br />
cd Mudlet && mkdir build<br />
<br />
'''3. Setup your environment'''<br />
./CI/travis.osx.before_install.sh<br />
./CI/travis.osx.install.sh<br />
<br />
luarocks config lua_version 5.1<br />
eval `luarocks path --lua-version=5.1`<br />
For the following, one may have to add <code>''_DIR="/opt/homebrew/"''</code> such as <code>PCRE_DIR="/opt/homebrew/"</code> or <code>ZIP_DIR="/opt/homebrew/"</code> if the installation could not find header files.<br />
luarocks --lua-version=5.1 --lua-dir=`brew --prefix lua@5.1` install lrexlib-pcre PCRE_DIR=`brew --prefix pcre`<br />
brew install sqlite<br />
luarocks --lua-version=5.1 --lua-dir=`brew --prefix lua@5.1` install luasql-sqlite3 SQLITE_DIR=`brew --prefix sqlite` <br />
luarocks --lua-version=5.1 --lua-dir=`brew --prefix lua@5.1` install luautf8<br />
luarocks --lua-version=5.1 --lua-dir=`brew --prefix lua@5.1` install luafilesystem<br />
luarocks --lua-version=5.1 --lua-dir=`brew --prefix lua@5.1` install lua-zip ZIP_DIR=`brew --prefix libzip`<br />
<br />
brew install boost<br />
OK to answer yes to delete files if prompted for the <code>rm</code> command above.<br />
<br />
'''4. Run the following commands'''<br />
<br />
cd build<br />
cmake ../../Mudlet -DCMAKE_PREFIX_PATH=`brew --prefix qt5`<br />
make -j `sysctl -n hw.ncpu`<br />
<br />
<br />
'''5. Enjoy'''<br />
<br />
The mudlet.app is now available in <code>src/</code> for launching:<br />
<br />
open src/Mudlet.app<br />
<br />
'''6. Qt Creator setup'''<br />
<br />
No Lua installation is found, despite it existing on your system? Launch Qt Creator by doing <code>open /Applications/Qt Creator.app</code> (location depends on how you installed it).<br />
<br />
Receiving a <code>No rule to make target ... libQt5UiTools_debug.a</code> error? A workaround is to [https://bugreports.qt.io/browse/QTBUG-81251?focusedCommentId=538705&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-538705 symlink a file].<br />
<br />
Mudlet in Qt Creator is not launching due to <code>dyld: Symbol not found: __cg_jpeg_resync_to_restart</code>? See [https://stackoverflow.com/a/44851430/72944 here] for a workaround.<br />
<br />
====== 7. Troubleshooting ======<br />
If you exhaust all efforts to get YAJL to compile on your local system with homebrew, [https://github.com/lloyd/yajl/ clone from the YAJL repository] then <code>./configure && sudo make install</code>.<br />
<br />
== Compiling on Debian 'Sid' ==<br />
<br />
'''1. Install required packages from main repo.'''<br />
<br />
sudo apt-get install build-essential git liblua5.1-dev zlib1g-dev libhunspell-dev libpcre3-dev \<br />
libzip-dev libboost-dev libyajl-dev libpulse-dev lua-rex-pcre lua-filesystem lua-zip \<br />
lua-sql-sqlite3 qt5-default qtmultimedia5-dev qttools5-dev luarocks ccache libpugixml-dev<br />
<br />
sudo luarocks install luautf8<br />
sudo luarocks install lua-yajl<br />
<br />
'''2. Grab latest Mudlet source.'''<br />
<br />
mkdir ~/projects && cd ~/projects && git clone --recursive https://github.com/Mudlet/Mudlet.git mudlet<br />
<br />
'''3. Build Mudlet.'''<br />
<br />
cd ~/projects/mudlet/src<br />
<br />
qmake<br />
<br />
make<br />
<br />
sudo make install<br />
<br />
== Compiling on Debian 11 'Bullseye' ==<br />
<br />
'''1. Install required packages.'''<br />
<br />
sudo apt-get install build-essential git liblua5.1-dev zlib1g-dev libhunspell-dev libpcre3-dev \<br />
libzip-dev libboost-dev libyajl-dev libpulse-dev lua-rex-pcre lua-filesystem lua-zip \<br />
lua-sql-sqlite3 qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qtmultimedia5-dev \<br />
qttools5-dev luarocks ccache libpugixml-dev libqt5texttospeech5-dev qtspeech5-flite-plugin \<br />
qtspeech5-speechd-plugin libqt5opengl5-dev ninja-build cmake libsecret-1-dev<br />
<br />
sudo luarocks install luautf8 <br />
sudo luarocks install lua-yajl<br />
<br />
'''2. Get Mudlet source.'''<br />
<br />
mkdir ~/source && cd ~/source<br />
<br />
git clone --recursive https://github.com/Mudlet/Mudlet.git<br />
<br />
Note: the line above will check out `development` branch source code, and this might not always be stable. You can check out the latest release source code using this command:<br />
<br />
git clone --recursive --branch main https://github.com/Mudlet/Mudlet.git<br />
<br />
'''3. Build Mudlet.'''<br />
<br />
mkdir ~/source/Mudlet/build && cd ~/source/Mudlet/build<br />
<br />
qmake ../src/mudlet.pro<br />
<br />
make -j `nproc`<br />
<br />
sudo make install<br />
<br />
After these steps you can run Mudlet by typing:<br />
<br />
mudlet<br />
<br />
'''4. (Optional) Discord library'''<br />
<br />
If you get the following error;<br />
<br />
Could not find Discord library - searched in:<br />
<br />
you need to specify the discord library in your build. Run the following, changing the path where necessary;<br />
<br />
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/user/mudlet-dev/Mudlet/3rdparty/discord/rpc/lib/<br />
<br />
and recompile. You should see<br />
<br />
Discord integration loaded. Using functions from: "libdiscord-rpc.so"<br />
<br />
== Compiling on Raspberry Pi OS ==<br />
<br />
These instructions will get you compiling and running Mudlet on Raspberry Pi OS (Buster). Need a hand? Join us on Mudlet's [https://discord.gg/BwgJpMj Discord] or [http://forums.mudlet.org/viewforum.php?f=7 forums].<br />
<br />
''' 1.a Install apt dependencies '''<br />
<br />
sudo apt-get update<br />
sudo apt-get install build-essential git liblua5.1-dev zlib1g-dev libhunspell-dev libpcre3-dev \<br />
libzip-dev libboost-graph-dev libyajl-dev libpulse-dev lua-rex-pcre lua-filesystem lua-zip \<br />
lua-sql-sqlite3 qt5-default qtmultimedia5-dev qttools5-dev luarocks ccache libpugixml-dev cmake<br />
<br />
<br />
[[File:Apt-get-install-y-n.png|center|thumb|installing apt dependencies]]<br />
<br />
''' 1.b Install luarocks dependencies '''<br />
<br />
sudo luarocks install luautf8 <br />
sudo luarocks install lua-yajl YAJL_LIBDIR=`find /usr -name "libyajl.so" -printf '%h\n'` YAJL_INCDIR=/usr/include<br />
<br />
<br />
[[File:After-luarocks-dependencies.png|center|thumb|after luarocks dependencies]]<br />
<br />
''' 2. Get Mudlet source '''<br />
<br />
mkdir ~/source && cd ~/source <br />
git clone --recursive -b development https://github.com/Mudlet/Mudlet.git<br />
<br />
[[File:After-get-mudlet-source.png|center|thumb|After cloning]]<br />
<br />
''' 3. Create a build directory '''<br />
<br />
cd Mudlet && mkdir build && cd build<br />
<br />
''' 4. Run the following commands to build '''<br />
<br />
WITH_UPDATER=NO WITH_3DMAPPER=NO qmake ../src/mudlet.pro<br />
<br />
:If you get a response along the lines of:<br />
<br />
qmake: could not find a Qt installation of ''<br />
<br />
:then you likely have ''qtchooser'' present in your system that allows for both Qt4 and Qt5 (or more than one Qt5 version) and it modifiers qmake and some other Qt development programs to take an additional argument to specify which version to use. In that case you should use:<br />
<br />
WITH_UPDATER=NO WITH_3DMAPPER=NO qmake -qt=qt5 ../src/mudlet.pro<br />
<br />
[[File:After-qmake.png|center|thumb|After qmake]]<br />
<br />
''' THEN: '''<br />
:For the fastest compile time while still being able to use the system at all (~35min on a RPi4 with 4GB of ram)<br />
make -j $(expr `nproc` - 1)<br />
<br />
''' OR: '''<br />
<br />
:Use this if you have an older Raspberry Pi. Be prepared for it to take a while (over an hour) - ''it is not recommended to try to more than one compilation task at a time on the older systems with the '''-j''' option as they will only have a system memory with enough space for one of some of those tasks'':<br />
make<br />
<br />
[[File:Success.png|center|thumb|Success!]]<br />
<br />
''' 4. Install the application you have just compiled '''<br />
<br />
sudo make install<br />
<br />
[[File:Installed.png|center|thumb|Installed now]]<br />
<br />
''' 5. Enjoy! '''<br />
<br />
# mudlet is in the path, can just run it<br />
mudlet<br />
<br />
== Compiling on Arch Linux ==<br />
<br />
===AUR Install and Compile===<br />
Mudlet is available in the [https://aur.archlinux.org Arch User Repository].<br />
(If the AUR has become unmaintained/orphaned, then skip below to [https://wiki.mudlet.org/w/Compiling_Mudlet#Manual_Install_and_Compile Manual install].)<br />
<br />
To install it use your favourite AUR helper (helper tool will automatically resove dependancies); example using ''yay'' :<br />
yay -S mudlet<br />
<br />
For more info on this process, visit [https://wiki.archlinux.org/index.php/Arch_User_Repository Arch User Repository - ArchWiki].<br />
<br />
''Note: For the most recent development version of Mudlet, replace 'mudlet' with 'mudlet-git' in the above commands and proceed as described.''<br />
<br />
''Built in fonts have been disabled, but are available in packages listed as optional dependancies.''<br />
<br />
''Discord support in Mudlet depends on an external library provided by discord-rpc-api, which is also available in AUR, choose whichever variant suits you best.''<br />
<br />
===Manual Install and Compile===<br />
These instructions will get you setup compiling on Arch. Need a hand? Join us on Mudlet's [https://discord.gg/BwgJpMj Discord] or [http://forums.mudlet.org/viewforum.php?f=7 forums].<br />
<br />
'''1. necessary dependencies'''<br />
<br />
Majority of required dependencies can be obtained from repositories, and can be installed with following command:<br />
<br />
sudo pacman -S --needed cmake qt5-multimedia hunspell libzip lua51-filesystem qt5-gamepad lua51-luautf8 pugixml \<br />
ttf-font qtkeychain-qt5 boost qt5-tools ttf-bitstream-vera ttf-ubuntu-font-family noto-fonts-emoji glu luarocks<br />
<br />
Few of required Lua modules are not available in official repositories, so they have to be installed using ''luarocks''<br />
sudo lua5.1 /usr/bin/luarocks install lcf<br />
sudo lua5.1 /usr/bin/luarocks install luautf8<br />
sudo lua5.1 /usr/bin/luarocks install lua-yajl<br />
sudo lua5.1 /usr/bin/luarocks install lrexlib-pcre<br />
sudo lua5.1 /usr/bin/luarocks install luasql-sqlite3<br />
sudo lua5.1 /usr/bin/luarocks install lua-zip<br />
<br />
There is an optional dependency for discord integration:<br />
git clone https://github.com/discord/discord-rpc<br />
cd discord-rpc<br />
mkdir build<br />
cd build<br />
cmake .. -DCMAKE_INSTALL_PREFIX=/usr<br />
sudo cmake --build . --config Release --target install<br />
<br />
'''2. obtaining the source code'''<br />
<br />
Obtain the latest in-development code with:<br />
git clone --recursive -b development https://github.com/Mudlet/Mudlet.git<br />
mkdir Mudlet/build<br />
cd Mudlet/build<br />
<br />
'''3. compiling the code'''<br />
<br />
There below are two ways to build with qmake, the first is for general use, the second is for developers:<br />
qmake ../src/mudlet.pro<br />
'''*OR*'''<br />
qmake CONFIG+=debug ../src/mudlet.pro<br />
<br />
'''Now finish compiling:'''<br />
make -j `nproc`<br />
<br />
'''4. installing compiled code'''<br />
<br />
After successful code compilation, next few commands will install resulting binaries, desktop file for menus and appropriate icon.<br />
sudo make install<br />
sudo cp ../mudlet.png /usr/share/pixmaps<br />
sudo cp ../mudlet.desktop /usr/share/applications<br />
<br />
'''5. optional additional software'''<br />
<br />
One of the major reasons for compiling Mudlet from source is the ability to unlock more features that are not enabled in official AppImage.<br />
Manual compilation will resolve the issues with sound by using system provided libraries, as well as enable more detailed theming of Mudlet application itself.<br />
However, do take note that Mudlet is a Qt based program, and that theming will not 'just work' in GTK based desktop environments (Gnome, XFCE, MATE, Budgie).<br />
sudo pacman -S install qt5ct<br />
will install a tool for configuration of look and feel of Qt programs inside those desktop environments.↵Users of Qt based Desktop environments (KDE Plasma, LXQT) can simply use settings provided by environment itself.<br />
<br />
Many of Qt widget styles and color schemes are available in official repositories, and will make Mudlet better.<br />
<br />
6. '''Mudlet on Wayland'''<br />
<br />
Mudlet compiled like this will run and work on Wayland, however, there are a few quirks with Keybindings (Numpad may not work as expected).<br />
Until that is resolved you may wish to start mudlet with:<br />
QT_QPA_PLATFORM=xcb mudlet<br />
(enter in terminal or simply change the Exec= line in /usr/share/applications/mudlet.desktop)<br />
<br />
7. '''uninstallation'''<br />
<br />
You can reverse the process described in this guide with following command:<br />
<br />
sudo rm -fr /usr/bin/mudlet /usr/share/mudlet /usr/share/applications/mudlet.desktop /usr/share/pixmaps/mudlet.png<br />
<br />
== Compiling on Fedora (aarch64) ==<br />
<br />
'''1. Install dependencies'''<br />
sudo dnf groupinstall "Development Tools" "Development Libraries"<br />
<br />
sudo dnf install compat-lua compat-lua-devel compat-lua-libs hunspell-devel lua5.1-filesystem luarocks pugixml-devel qtkeychain-qt5-devel bitstream-vera-fonts-all ccache qt-creator qt5-qtmultimedia-devel qt5-qtgamepad-devel yajl-devel qtchooser qt5-qttools-devel qt5-qttools-static zziplib-devel pcre-devel libzip-devel sqlite-devel<br />
<br />
sudo luarocks --lua-version 5.1 --tree=/usr install luazip<br />
sudo luarocks --lua-version 5.1 --tree=/usr install luasql-sqlite3<br />
sudo luarocks --lua-version 5.1 --tree=/usr install lcf<br />
sudo luarocks --lua-version 5.1 --tree=/usr install luautf8<br />
sudo luarocks --lua-version 5.1 --tree=/usr install lua-yajl<br />
sudo luarocks --lua-version 5.1 --tree=/usr install lrexlib-pcre<br />
In your user's home directory:<br />
<br />
If you use a bash shell:<br />
luarocks --lua-version 5.1 path --no-bin >> .bashenv<br />
source .bashenv<br />
If you use a zsh shell:<br />
luarocks --lua-version 5.1 path --no-bin >> .zshenv<br />
source .zshenv<br />
If you use a csh shell:<br />
luarocks --lua-version 5.1 path --no-bin >> .cshenv<br />
source .cshenv<br />
This should cover paths, but you may want to reboot to be sure.<br />
<br />
'''2. Obtain the source code'''<br />
git clone --recursive --branch=development <nowiki>https://github.com/Mudlet/Mudlet.git</nowiki><br />
mkdir Mudlet/build<br />
cd Mudlet/src<br />
<br />
'''3. Make necessary compiling instruction adjustments'''<br />
<br />
Edit mudlet.pro - find these lines in mudlet.pro and make the following changes:<br />
linux {<br />
LIBS += \<br />
-llua5.1 \<br />
-lhunspell<br />
INCLUDEPATH += /usr/include/lua5.1<br />
}<br />
We're adding a - between lua and 5.1 and adding -1.7 to hunspell under LIBS so that it becomes this:<br />
linux {<br />
LIBS += \<br />
-llua-5.1 \<br />
-lhunspell-1.7<br />
INCLUDEPATH += /usr/include/lua5.1<br />
}<br />
Save and exit.<br />
<br />
'''4. Compile'''<br />
cd ../build<br />
Run this in the build directory:<br />
WITH_FONTS=NO WITH_OWN_QTKEYCHAIN=NO WITH_UPDATER=NO WITH_VARIABLE_SPLASH_SCREEN=NO XDG_DATA_DIRS=/usr/share qmake-qt5 PREFIX=/usr INCLUDEPATH+=/usr/include/lua-5.1 LUA_SEARCH_OUT=lua-5.1 ../src/mudlet.pro<br />
An explanation of the qmake arguments -- we're passing these environment variables to mudlet.pro:<br />
WITH_FONTS=NO WITH_OWN_KEYCHAIN=NO WITH_UPDATER=NO WITH_VARIABLE_SPLASH_SCREEN=NO XDG_DATA_DIRS=/usr/share<br />
Adding build variables to mudlet.pro so that it finds the correct libraries:<br />
PREFIX=/usr INCLUDEPATH+=/usr/include/lua-5.1<br />
And finally adding a build variable to translations/translated/updateqm.pri so that it uses the correct version of the Lua compiler (Fedora also comes with 5.4) to generate translation statistics.<br />
LUA_SEARCH_OUT=lua-5.1<br />
Once complete, run the following:<br />
<br />
If you have time to kill (About 10 minutes on an Apple M1 Max in Fedora):<br />
make<br />
If you want it done as fast as possible(Less than a minute on an Apple M1 Max in Fedora):<br />
make -j `nproc`<br />
Or if you want something in between, make -j `nproc` tells it to use all available processor cores. If you want to use a specific number instead (ie 2), you can use:<br />
make -j 2<br />
<br />
'''5. Install'''<br />
sudo make install<br />
sudo cp ../mudlet.png /usr/share/pixmaps<br />
sudo cp ../mudlet.desktop /usr/share/applications<br />
<br />
'''6. Hang onto the cloned git repo '''<br />
If you need to uninstall, you can go back into the /build directory and 'sudo make uninstall'.<br />
<br />
== Compiling on Gentoo ==<br />
An [https://github.com/toaster/gentoo-overlay overlay containing Mudlet is available] for compiling Mudlet on Gentoo.<br />
<br />
== Compiling on Windows ==<br />
<br />
These instructions will get you setup compiling on Windows. <br />
<br />
Need a hand? Join us on the Mudlet [https://discord.gg/BwgJpMj Discord server] or [http://forums.mudlet.org/viewforum.php?f=7 forums].<br />
<br />
'''1. Download Mudlet source code'''<br />
<br />
# Install [https://desktop.github.com/ Github Desktop].<br />
# Clone ([https://help.github.com/desktop/guides/contributing-to-projects/cloning-a-repository-from-github-to-github-desktop/#platform-windows instructions]) Mudlet's [https://github.com/mudlet/mudlet repository] to your local drive.<br />
{{note}} You must use a location on <code>C:\</code> without any spaces in folder names! <br />
<br />
'''2. Perform a one-time setup'''<br />
<br />
* Open powershell in the newly cloned folder by typing in <code>powershell</code> in the address bar:<br />
<br />
[[File:Open powershell in a folder.png|none|thumb|418x418px]]<br />
<br />
* Run <code>Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted</code> to enable the setup script to run and press <code>A</code>.<br />
* Run <code>./setup-windows-sdk.ps1</code><br />
<br />
This will automatically download all of the requires tools (including Python 2) and libraries, set them up for you, build Mudlet, and launch it! <br />
<br />
{{note}} If this script exits immediately, please [https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/install/installing-windows-powershell?view=powershell-7.1#upgrading-existing-windows-powershell upgrade your PowerShell version] first. You may also need to [https://learn.microsoft.com/de-de/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4 allow to run scripts from the internet]<br />
<br />
{{note}} Depending on your Internet connection and computer speed, this one-time setup will take 30 minutes or more - so grab a cup of tea or coffee.<br />
<br />
'''3. Watch the magic happen'''<br />
<br />
Here is a video recording of the setup unfolding, compiling, etc. for your comparsion:<br />
<br />
[[File:Start-of-installation.gif|frame|none|Sometimes the output will get stuck and not progress - just press Enter to make it continue. This is a well-known [https://serverfault.com/questions/204150/sometimes-powershell-stops-sending-output-until-i-press-enter-why Powershell bug.]]]<br />
<br />
During the installation, you'll see the Qt installer window pop-up - this is normal:<br />
<br />
[[File:Qt-installer.gif|thumb|none]]<br />
<br />
The Qt installer might ask you about your data collection preferences - answer as you wish and the automated install will continue:<br />
<br />
[[File:Qt-installer-data-collection.png|thumb|none]]<br />
<br />
The installer's final step will be compiling all of the source code, which looks like this:<br />
<br />
[[File:Compiling-step.gif|thumb|none]]<br />
<br />
After it's all done, a Mudlet version ending in "-dev" will launch automatically:<br />
<br />
[[File:Mudlet-launching.gif|frame|none]]<br />
<br />
If something didn't work right, you can check out the verbose log that is available at <code>C:\src\verbose_output.log</code>.<br />
<br />
=== Coding on Mudlet ===<br />
<br />
Open <code>C:\<path to repository>\src\mudlet.pro</code> in Qt Creator, which resides here: <code>C:\Qt\Tools\QtCreator\bin\qtcreator.exe</code>. Then enable Debug and Release builds and hit ''Configure Project'':<br />
<br />
[[File:Selection_173.png|frame|none]]<br />
<br />
Press <code>Ctrl+5</code> and update project settings. Check how many logical processors are available in your system with the Task Manager:<br />
<br />
[[File:Task-manager.png|thumb|none|2 processors are available in this example]]<br />
<br />
And set this amount in Qt Creator:<br />
<br />
[[File:Change Qt Creator to use many cores.gif|frame|none]]<br />
<br />
Hit run:<br />
<br />
[[File:Selection 176.png|frame|none]]<br />
<br />
Click on '''Compile Output''' to see progress on compiling:<br />
<br />
[[File:Selection 177.png|frame|none]]<br />
<br />
When it's all ready, the new Mudlet with your changes will launch. '''You're all done'''!<br />
<br />
=== Contributing changes ===<br />
<br />
Once you're all done with your changes, contribute them to Mudlet using a [https://help.github.com/desktop/guides/contributing-to-projects/creating-a-pull-request/#platform-windows pull request]. Thanks for improving open-source!<br />
<br />
=== Uninstalling ===<br />
To get rid of everything, remove the following folders:<br />
<br />
C:\Libraries<br />
C:\LuaRocks<br />
C:\MinGW<br />
C:\Python27<br />
C:\Qt<br />
C:\src<br />
<br />
== Compiling on Github Codespaces ==<br />
<br />
[https://github.com/features/codespaces/ Github Codespaces] allow you to code and run Mudlet all from the browser - makes it a lot easier to get started. It also allows you to code Mudlet itself from any computer in the world! <br />
<br />
'''1. Create a new codespace'''<br />
<br />
Create a new Codespace by going to https://github.com/Mudlet/Mudlet using Google Chrome or Microsoft Edge (Firefox at the time of the writing doesn't have working copy/paste). There, click the green "Code" button, select the "Codespaces" tab and click "New codespace".<br />
<br />
[[File:New codespace.png|alt=New codespace screenshot|frameless]]<br />
<br />
'''2. Wait for it to load'''<br />
<br />
This will take a while (~5min) so grab a tea:<br />
<br />
[[File:Building Visual Studio Codespace.png|frameless]]<br />
<br />
'''3. Connect to the environment'''<br />
<br />
Go to the <code>Ports</code> section at the bottom and change the Port Privacy of the Open Mudlet port to Public:<br />
<br />
[[File:Port privacy in Github Codespaces.png|900x900px]]<br />
<br />
<br />
Then connect to your online Linux desktop with <code>mudlet</code> as the password by clicking on the web icon. <br />
<br />
[[File:Connect to remote machine.png|frameless]]<br />
<br />
<br />
In case it can't connect, make sure the port privacy is set to <code>Public</code>. If it still can't connect, try 4-5 more times - eventually it'll work.<br />
<br />
<br />
<br />
We chose a retro 90's look here to fit with the whole hacking theme, so if you see this you're good 😉<br />
<br />
[[File:Github_codespaces_desktop.png|alt=|frameless|400x400px]]<br />
<br />
'''4. Build Mudlet'''<br />
<br />
In Codespaces, hit <code>F7</code> and select <code>Let CMake guess...</code><br />
<br />
[[File:CMake configuration.png|none]]<br />
<br />
It will then start building Mudlet automatically. Using the [https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces/about-billing-for-codespaces Basic instance] (only kind available in beta) the first-time build will take ~25min, so take a break here - you've made excellent progress. All follow-up compiles after this will be quicker, by the way.<br />
<br />
[[File:Building Mudlet in codespaces.png|none]]<br />
<br />
'''5. Run Mudlet'''<br />
<br />
[[File:Launch Mudlet.png|none]]<br />
<br />
Hit the little play button at the bottom of the screen, and Mudlet will now launch in the remote connection tab. Not working? [https://discord.gg/kuYvMQ9 We can help]. Otherwise, enjoy!<br />
<br />
[[File:Mudlet running remotely.png |500px]]<br />
<br />
Note: When the codespace is unused for a while, it will disconnect. It'll never disconnect while you're actively using it. See [https://github.com/microsoft/vscode-dev-containers/issues/588 Github issue] for details.<br />
<br />
== Developing with Docker ==<br />
<br />
Docker is a system designed for more reproducible and isolated builds. A docker setup exists and has been tested using Pop OS! 20.04 (which is derived from Ubuntu 20.04). First, follow the instructions to install both [https://docs.docker.com/get-docker/ docker] and [https://docs.docker.com/compose/install/ docker-compose].<br />
<br />
Clone the development branch<br />
<br />
git clone --recursive -b development https://github.com/Mudlet/Mudlet.git<br />
cd Mudlet/docker<br />
<br />
Make a local copy of the .env.template file:<br />
<br />
cp .env.template .env<br />
<br />
If you wish to customize things like the number of cores to use for building mudlet, feel free to change the corresponding values in the .env file.<br />
<br />
To run Qt-Creator and develop Mudlet, run <code>docker-compose up dev</code>.<br />
<br />
To run Mudlet, run <code>docker-compose up mudlet</code>. Note: At the moment, the mudlet build will not persist settings past container rebuilds.<br />
<br />
== Compiling on Windows 7+ (MSYS2 Alternative)==<br />
<br />
''INCOMPLETE, IN PROGRESS''<br />
<br />
Go to http://www.msys2.org/ to download the 64 bit MSYS2 installer (as of 2020/05/24 32 bit hosts - for '''compiling''' software, but ''not'' for using code built with it have been deprecated, the last installer for that 32-bit systems is held at: http://repo.msys2.org/distrib/i686/msys2-i686-20200517.exe) and follow the installation instructions (Steps 1 to 8 on that page), these instructions assume that "C:\msys64" or "C:\msys32" is used depending on the bitness of the system it is being installed on.<br />
<br />
Install the following packages (using "pacman -S ''packageName''"), the ones with a '''-i686-''' in the middle are the ones for 32-bit (i686) targets and '''-x86_64-''' are the ones for 64-bit targets - it is possible to install both for building Mudlet for target PCs of both bitnesses on a 64-bit host, it is not clear whether the reverse is true with a 32-bit host. These will pull in a number of other required packages as well (the ''--needed'' option prevents the re-installation of packages that have already been installed by MSYS2/Mingw-w64's own setup/installation process) - as some of the packages, e.g. ''base-devel'' are actually ''groups'' you will be requested to select which members of that group are actually required, it is easiest to just go with the default which is to install ALL of the packages in that group!<br />
<br />
: For 32-Bit Mudlet builds:<br />
:<syntaxhighlight lang="shell"><br />
MSYS user@computer ~<br />
$ pacman -S --needed base-devel git mercurial cvs wget ruby zip p7zip python mingw-w64-i686-toolchain mingw-w64-i686-qt-creator mingw-w64-i686-qt5-multimedia mingw-w64-i686-libzip mingw-w64-i686-pugixml mingw-w64-i686-lua51 mingw-w64-i686-lua51-lpeg mingw-w64-i686-lua51-lsqlite3 mingw-w64-i686-hunspell mingw-w64-i686-boost mingw-w64-i686-yajl mingw-w64-i686-clang mingw-w64-i686-cmake mingw-w64-i686-SDL unzip<br />
</syntaxhighlight><br />
<br />
: For 64-Bit Mudlet builds:<br />
:<syntaxhighlight lang="shell"><br />
MSYS user@computer ~<br />
$ pacman -S --needed base-devel git mercurial cvs wget ruby zip p7zip python mingw-w64-x86_64-toolchain mingw-w64-x86_64-qt-creator mingw-w64-x86_64-qt5-multimedia mingw-w64-x86_64-libzip mingw-w64-x86_64-pugixml mingw-w64-x86_64-lua51 mingw-w64-x86_64-lua51-lpeg mingw-w64-x86_64-lua51-lsqlite3 mingw-w64-x86_64-hunspell mingw-w64-x86_64-boost mingw-w64-x86_64-yajl mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-SDL unzip<br />
</syntaxhighlight><br />
<br />
::The ''*-zziplib'' libraries are used by the ''luazip'' luarock {from the Kepler project} but Mudlet will work perfectly well with the alternative ''lua-zip'' {from the brimworks GitHub repository - which also provides the ''lua-yajl'' rock} which does not require this library - although it is possible that it might still be pulled into the system as a dependency of another MSYS2 package.<br />
<br />
:Note that this will install the MSYS2 builds of the Qt Libraries and Creator IDE - ''THE ON/OFF-LINE INSTALLER OF THE QT LIBRARIES AND CREATOR VIA DOWNLOADS FROM QT ARE NOT USEFUL IN THIS SETUP!''<br />
<br />
:{| class="wikitable"<br />
|-<br />
|'''Attention - Luarocks packages problem'''<br />
|-<br />
| Recently the Luarocks project attempted to adopt the MSYS2/Mingw-w64 platform as one it would supported natively and the MSYS2/Mingw-w64 project went and upgraded its luarocks packages to make use of the changes and also on-board other improvements (and the version number increased from ''2.4.4-2'' to ''3.5.0-1'') unfortunately this completely broke them and although the issue has been reported ([https://github.com/msys2/MINGW-packages/issues/9037 MSYS2 Issue 9037]) a fix has not yet materialised. The only way to work around this in the meantime is to download the older package (with '''wget''') and install it manually (with '''pacman -U):<br />
|-<br />
|For 32-Bit Mudlet builds:<br />
:<syntaxhighlight lang="shell"><br />
MSYS user@computer ~<br />
$ wget https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-lua51-luarocks-2.4.4-2-any.pkg.tar.zst<br />
--2021-07-07 22:19:09-- https://repo.msys2.org/mingw/mingw32/mingw-w64-i686-lua51-luarocks-2.4.4-2-any.pkg.tar.zst<br />
Resolving repo.msys2.org (repo.msys2.org)... 178.63.98.68<br />
Connecting to repo.msys2.org (repo.msys2.org)|178.63.98.68|:443... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 97905 (96K) [application/octet-stream]<br />
Saving to: ‘mingw-w64-i686-lua51-luarocks-2.4.4-2-any.pkg.tar.zst’<br />
<br />
mingw-w64-i686-lua51-luarocks-2.4.4-2- 100%[===========================================================================>] 95.61K --.-KB/s in 0.07s<br />
<br />
2021-07-07 22:19:10 (1.43 MB/s) - ‘mingw-w64-i686-lua51-luarocks-2.4.4-2-any.pkg.tar.zst’ saved [97905/97905]<br />
<br />
<br />
MSYS user@computer ~<br />
$ pacman -U mingw-w64-i686-lua51-luarocks-2.4.4-2-any.pkg.tar.zst<br />
loading packages...<br />
resolving dependencies...<br />
looking for conflicting packages...<br />
<br />
Packages (1) mingw-w64-i686-lua51-luarocks-2.4.4-2<br />
<br />
Total Installed Size: 0.46 MiB<br />
<br />
:: Proceed with installation? [Y/n] y<br />
(1/1) checking keys in keyring [#####################################################] 100%<br />
(1/1) checking package integrity [#####################################################] 100%<br />
(1/1) loading package files [#####################################################] 100%<br />
(1/1) checking for file conflicts [#####################################################] 100%<br />
(1/1) checking available disk space [#####################################################] 100%<br />
:: Processing package changes...<br />
(1/1) installing mingw-w64-i686-lua51-luarocks [#####################################################] 100%<br />
<br />
MSYS user@computer ~<br />
</syntaxhighlight><br />
|-<br />
|For 64-Bit Mudlet builds:<br />
:<syntaxhighlight lang="shell"><br />
MSYS user@computer ~<br />
$ wget https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-lua51-luarocks-2.4.4-2-any.pkg.tar.zst<br />
--2021-07-07 22:17:32-- https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-lua51-luarocks-2.4.4-2-any.pkg.tar.zst<br />
Resolving repo.msys2.org (repo.msys2.org)... 178.63.98.68<br />
Connecting to repo.msys2.org (repo.msys2.org)|178.63.98.68|:443... connected.<br />
HTTP request sent, awaiting response... 200 OK<br />
Length: 97935 (96K) [application/octet-stream]<br />
Saving to: ‘mingw-w64-x86_64-lua51-luarocks-2.4.4-2-any.pkg.tar.zst’<br />
<br />
mingw-w64-x86_64-lua51-luarocks-2.4.4- 100%[===========================================================================>] 95.64K --.-KB/s in 0.07s<br />
<br />
2021-07-07 22:17:32 (1.28 MB/s) - ‘mingw-w64-x86_64-lua51-luarocks-2.4.4-2-any.pkg.tar.zst’ saved [97935/97935]<br />
<br />
<br />
MSYS user@computer ~<br />
$ pacman -U mingw-w64-x86_64-lua51-luarocks-2.4.4-2-any.pkg.tar.zst<br />
loading packages...<br />
resolving dependencies...<br />
looking for conflicting packages...<br />
<br />
Packages (1) mingw-w64-x86_64-lua51-luarocks-2.4.4-2<br />
<br />
Total Installed Size: 0.46 MiB<br />
<br />
:: Proceed with installation? [Y/n] y<br />
(1/1) checking keys in keyring [#####################################################] 100%<br />
(1/1) checking package integrity [#####################################################] 100%<br />
(1/1) loading package files [#####################################################] 100%<br />
(1/1) checking for file conflicts [#####################################################] 100%<br />
(1/1) checking available disk space [#####################################################] 100%<br />
:: Processing package changes...<br />
(1/1) installing mingw-w64-x86_64-lua51-luarocks [#####################################################] 100%<br />
<br />
MSYS user@computer ~<br />
</syntaxhighlight><br />
|}<br />
<br />
::{| class="wikitable"<br />
|-<br />
|'''Warning for those planning to build ''both'' 32 and 64 bit versions'''<br />
|-<br />
|If one is planning to build ''both'' bitness binaries an additional step is necessary as, by default, the MSYS2/Mingw-w64 ''luarocks'' setup seems to place any ''.lua'' or ''.dll'' modules it builds/installs on a per user (the so-called ''local'' basis) into the same directories with the same names. This is no good for two reasons:<br />
* It is difficult to work out which bitness a particular module is for and whilst 32-bit modules ''might'' work in a 64-bit environment the reverse is definitely not the case<br />
* It confuses the Luarocks package management systems (as effectively there will be two different luarocks systems operated side-by-side)<br />
<br />
This can be worked around by:<br />
* Editing the '''.\etc\luarocks\config-5.1.lua''' for each bitness so that the ''rocks_trees'' table entry for the ''user'' key is changed from this in '''both''' files:<br />
:<syntaxhighlight lang="lua"> { name = [[user]], root = home..[[/.luarocks]] },</syntaxhighlight><br />
to something different for each of them, say, for example, for the the 64-bit one:<br />
:<syntaxhighlight lang="lua"> { name = [[user]], root = home..[[/.luarocks-x64]] },</syntaxhighlight><br />
* Then by specifying the ''rocktree'' name ('''user''') on the command line when '''installing''' or '''building''' a luarock with the ''--tree user'' argument - note that for some inexplicable reason the ''--local'' argument that '''''should''''' do the same thing does not seem to work for these two actions, it is not clear whether this is a MSYS2/Mingw-w64 specific issue or it goes further upstream to Luarocks in general. Thus, in the next step it will be necessary to change from using:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~<br />
$ luarocks install --local rockname<br />
</syntaxhighlight><br />
to, for the example given:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~<br />
$ luarocks install --tree user rockname<br />
</syntaxhighlight><br />
where ''user'' is the literal string "user" to match the Lua table key in the rock_trees and not, in this case, a representation of the user-name/account of the person performing the action.<br />
|}<br />
<br />
From the Windows ''Start menu'' start a shell appropriate for the target with the bitness to be built for i.e. '''"MSYS2 Mingw 32-Bit"''' or '''"MSYS2 Mingw 64-Bit"'''. This will likely position the current directory to the root directory of the MSYS2 environment, the text about the prompt line (the one with the "$") will contain three different bits of colored text '''username@computername'''; one of '''MSYS2'''/'''MINGW32'''/'''MINGW''' depending on the type of shell you currently in use and '''/''' representing the root directory (which will actually be the directory MSYS2 was installed to, for example on the author's system this is "C:/msys64"). Change to the home directory in MYSY by entering "cd" on its own with no argument (it will show up as '''~''' and it would work out to be, for '''user''' to be '''c:/msys64/home/user''' or '''c:/msys32/home/user''' (if both bitnessess are to be built it will be necessary to repeat the following step twice, one for each and also observe the steps in the above warning) install the following luarocks:<br />
<br />
:{| class="wikitable sortable"<br />
|-<br />
! rockname<br />
|-<br />
| lrexlib-pcre<br />
|-<br />
| lua-yajl<br />
|-<br />
| luafilesystem<br />
|-<br />
| luasql-sqlite3<br />
|-<br />
| luautf8<br />
|-<br />
| luazip or lua-zip<br />
|}<br />
by using:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~<br />
$ luarocks install [--local] rockname<br />
</syntaxhighlight><br />
The ''--local'' argument is an optional one that causes the luarock and the lua module to be installed on a per-user basis rather than on a system wide one, this may be important if the PC is used by multiple users and more than one of them uses Lua in any form.<br />
<br />
Now create somewhere to work on the Mudlet source, assuming that other software coding with other pieces of software will be done, create a sub-directory in the home directory, and then make one just for Mudlet under that:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~<br />
$ mkdir ./src<br />
<br />
MINGW64 user@computer ~<br />
$ mkdir ./src/mudlet<br />
</syntaxhighlight><br />
<br />
Change to that directory and get the source code:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~<br />
$ cd ./src/mudlet<br />
<br />
MINGW64 user@computer ~/src/mudlet<br />
$ git clone git://github.com/Mudlet/Mudlet.git .<br />
</syntaxhighlight><br />
<br />
If you are planning to contribute to the Mudlet code you will want to visit Github and create your own GitHub repository, you can then push commits (changes to the code) to there and raise a Pull Request for a Mudlet Maker to drag the changes over to the above repository. You will want to add your repository and perhaps those of some other contributors so you can track what they are doing and see/try/experiment with their PRs before they get merged. Therefore you will want to add some other repositories into the mix. The names you use to identify those other repositories will show up in any utility that works with the repository you have just created in the above "clone" operation and can be anything you like but it makes sense to have clear names. So to add "myName", and those of the leading active contributors to the Mudlet codebase you will use:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~/src/mudlet<br />
$ git remote add Mine https://github.com/myName/Mudlet.git<br />
<br />
MINGW64 user@computer ~/src/mudlet<br />
$ git remote add Vadim https://github.com/vadi2/Mudlet.git <br />
<br />
MINGW64 user@computer ~/src/mudlet<br />
$ git remote add SlySven https://github.com/SlySven/Mudlet.git<br />
<br />
MINGW64 user@computer ~/src/mudlet<br />
$ git remote add Kebap https://github.com/Kebap/Mudlet.git<br />
</syntaxhighlight><br />
<br />
Now obtain ''all'' the versions of the code with:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~/src/mudlet<br />
$ git fetch --all<br />
</syntaxhighlight><br />
<br />
This will produce a lot of lines of output the first time and it might take a little while on a slow connection...<br />
<br />
{Section missing - it turns out that the default GUI git tools that the author of this section would normally use: "gitk" and "git gui" have some problems in the versions currently supplied from the MSYS2 system - and it was necessary to import them from the set that the Git4Win have patched - see https://github.com/git-for-windows/git/wiki/Install-inside-MSYS2-proper }<br />
<br />
Some modifications to the qmake/cmake project files are needed and these are now supported in the main ''development'' branch in the upstream {the Mudlet organisation's own GitHub repository} which requires that there is an environmental variable '''WITH_MAIN_BUILD_SYSTEM''' and it is set to the (case-insensitive) value '''NO''':<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~/src/mudlet<br />
$ export WITH_MAIN_BUILD_SYSTEM=NO<br />
</syntaxhighlight><br />
<br />
Also the '''MINGW_BASE_DIR''' environmental variable will need to be set to the root directory for the MINGW-W64 installation for the appropriate bitness of the target to be made. For building on a 64-Bit Host {the PC that is ''compiling'' the code} to make a 64-Bit application this will likely be '''C:/msys64/mingw64''' and for a 32-Bit application it will probably be '''C:/msys64/ming32'''.<br />
: E.g. <syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~/src/mudlet<br />
$ export MINGW_BASE_DIR=C:/msys64/mingw64 # To build a 64-Bit Application with a 64-Bit system<br />
</syntaxhighlight><br />
<br />
: Or: <syntaxhighlight lang="shell"><br />
MINGW32 user@computer ~/src/mudlet<br />
$ export MINGW_BASE_DIR=C:/msys64/mingw32 # To build a 32-Bit Application with a 64-Bit system<br />
</syntaxhighlight><br />
<br />
Now checkout a branch {ideally, if working on solving a new issue, or adding a feature or resolving a bug, one should create a new branch that is a copy of the current, upstream ''development'' branch} and then work on it with Qt Creator:<br />
:<syntaxhighlight lang="shell"><br />
MINGW64 user@computer ~/src/mudlet<br />
$ qtcreator &<br />
</syntaxhighlight><br />
<br />
Load in the '''mudlet.pro''' ''qmake'' project file in the '''src''' subdirectory (e.g. for this example: '''c:/msys64/home/user/src/mudlet/src/mudlet.pro''') and get hacking...<br />
<br />
= Setting up IDEs =<br />
== CLion ==<br />
=== Qt not detected ===<br />
If you'd like to use CLion and it is giving the following error:<br />
<br />
<nowiki><br />
By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has<br />
asked CMake to find a package configuration file provided by "Qt5Core", but<br />
CMake did not find one.<br />
<br />
...<br />
</nowiki><br />
<br />
You can fix this by setting <code>-DCMAKE_PREFIX_PATH=<your Qt + version + compiler location></code>. For example: <code>-DCMAKE_PREFIX_PATH=/media/vadi/SSDer/Programs/Qt/5.14.2/gcc_64/</code> [[File:CLion CMake settings - finidng Qt.png|700px|none]]<br />
<br />
=== CLion setup on Windows ===<br />
After running <code>setup-windows-sdk.ps1</code> make sure to set Cmake options to:<br />
-DCMAKE_PREFIX_PATH=C:\Qt\Tools\mingw730_32;C:\Qt\5.14.2\mingw73_32 -DBoost_INCLUDE_DIR=C:\Libraries\boost_1_77_0<br />
''Directories might vary slightly, when different Qt, Boost or MinGW version will be used.''<br />
<br />
[[File:Clion Settings - Cmake.png|frameless|700x700px]]<br />
<br />
<br />
<br />
You will need 32 bit version of MinGW. Set it in the <code>Toolset</code> field to:<br />
C:\Qt\Tools\mingw730_32<br />
<br />
''Directory may be slightly different if MinGW version used will change.''<br />
<br />
[[File:Toolchain.png|frameless|700x700px]]<br />
<br />
=== Clang Tidy ===<br />
Ensure that CLion is set to run the project's [https://www.jetbrains.com/help/clion/clang-tidy-checks-support.html#paticularcheck .clang-tidy checks] with the <code>Prefer .clang-tidy files over IDE settings</code> option:<br />
<br />
[[File:Clang Tidy CLIon.png|700px|none]]<br />
<br />
This helps us catch any issues just a bit earlier.<br />
<br />
===Checking memory leaks & other issues (sanitizers)===<br />
Besides clang-tidy, it's also possible to enable clang sanitizers to double-check for issues:<br />
<br />
* [https://clang.llvm.org/docs/LeakSanitizer.html LeakSanitizer] for detecting memory leaks<br />
* [https://clang.llvm.org/docs/AddressSanitizer.html AddressSanitizer] for detecting most issues dealing with memory, such as out of bounds accesses to heap, stack, global and more<br />
* [https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html UndefinedBehaviourSanitizer] for detecting the use of various features of C/C++ that are explicitly listed as resulting in undefined behaviour (such as using misaligned or null pointer, conversion to, from, or between floating-point types which would overflow the destination, division by zero, etc)<br />
* [https://clang.llvm.org/docs/MemorySanitizer.html MemorySanitizer] for detecting reading uninitialised memory<br />
* [https://clang.llvm.org/docs/ThreadSanitizer.html ThreadSanitizer] for detecting threading issues<br />
<br />
To use the sanitisers, set the <code>USE_SANITIZER</code> CMake variable to one or several variables (separate by comma): <code>Address</code>, <code>Memory</code>, <code>MemoryWithOrigins</code>, <code>Undefined</code>, <code>Thread</code>, or <code>Leak</code><br />
<br />
To use them in CLion, adjust the CMake settings:<br />
<br />
[[File:Clion_cmake_settings.png|frameless|890x890px]]<br />
<br />
Not all sanitisers can be used with each other - in that case the cmake configuration won't allow you to continue.<br />
<br />
=== Clang Format ===<br />
Ensure that [https://www.jetbrains.com/help/clion/clangformat-as-alternative-formatter.html#clion-support CLion is set to use] the <code>.clang-format</code> formatting style:<br />
<br />
[[File:Clang-format CLion.png]]<br />
<br />
This helps keep the look'n'feel of the source code in a consistent manner, even with many people contributing to Mudlet.<br />
<br />
== Visual Studio Code ==<br />
<br />
To set the path in Visual Studio Code, open settings, search for <code>cmake environment</code> and set the <code>CMAKE_PREFIX_PATH</code> to your path, such as <code>/media/vadi/SSDer/Programs/Qt/5.14.2/gcc_64/</code>:<br />
<br />
[[File:CMake path in Visual Studio Code.png|none]]<br />
<br />
===Clang Tidy===<br />
clang-tidy catches common programming issues, run it by selecting 'Analysis' from the command palette (Ctrl+Shift+P by default):<br />
<br />
[[File:Clang-tidy in vscode.png|none]]<br />
<br />
It is also possible [https://devblogs.microsoft.com/cppblog/visual-studio-code-c-december-2021-update-clang-tidy/ check status of analysis and cancel if needed].<br />
<br />
===Checking memory leaks & other issues (sanitizers)===<br />
Besides clang-tidy, it's also possible to enable clang sanitizers to double-check for issues:<br />
<br />
* [https://clang.llvm.org/docs/LeakSanitizer.html LeakSanitizer] for detecting memory leaks<br />
* [https://clang.llvm.org/docs/AddressSanitizer.html AddressSanitizer] for detecting most issues dealing with memory, such as out of bounds accesses to heap, stack, global and more<br />
* [https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html UndefinedBehaviourSanitizer] for detecting the use of various features of C/C++ that are explicitly listed as resulting in undefined behaviour (such as using misaligned or null pointer, conversion to, from, or between floating-point types which would overflow the destination, division by zero, etc)<br />
* [https://clang.llvm.org/docs/MemorySanitizer.html MemorySanitizer] for detecting reading uninitialised memory<br />
* [https://clang.llvm.org/docs/ThreadSanitizer.html ThreadSanitizer] for detecting threading issues<br />
<br />
To use the sanitisers, set the <code>USE_SANITIZER</code> CMake variable to one or several variables (separate by comma): <code>Address</code>, <code>Memory</code>, <code>MemoryWithOrigins</code>, <code>Undefined</code>, <code>Thread</code>, or <code>Leak</code><br />
<br />
To use them in VSCode, set the <code>cmake.configureSettings</code> variable:<br />
<br />
[[File:Cmake.configureSettings option in vscode.png|frameless|890x890px]]<br />
<br />
[[File:Choosing which sanitizers in vscode to use.png|frameless|891x891px]]<br />
<br />
Not all sanitisers can be used with each other - in that case the cmake configuration won't allow you to continue.<br />
<br />
== Qt Creator==<br />
===Clang Tidy and Clazy===<br />
<br />
Configure Mudlet-specific checks for [https://clang.llvm.org/extra/clang-tidy/ clang-tidy] and [https://github.com/KDE/clazy clazy] tools help catch any issues early on. See [https://doc.qt.io/qtcreator/creator-clang-tools.html Qt Creator's instructions] for setting this up - clang-tidy can use the <code>.clang-tidy</code> file that's available at the root of the repository, and for clazy enable <code>level0</code> and <code>level1</code> checks.<br />
<br />
[[File:Clang tidy configuration.png|frame|none]]<br />
[[File:Clazy configuration.png|frame|none]]<br />
<br />
===Checking memory leaks & other issues (sanitizers)===<br />
Besides clang-tidy, it's also possible to enable clang sanitizers to double-check for issues:<br />
<br />
* [https://clang.llvm.org/docs/LeakSanitizer.html LeakSanitizer] for detecting memory leaks<br />
* [https://clang.llvm.org/docs/AddressSanitizer.html AddressSanitizer] for detecting most issues dealing with memory, such as out of bounds accesses to heap, stack, global and more<br />
* [https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html UndefinedBehaviourSanitizer] for detecting the use of various features of C/C++ that are explicitly listed as resulting in undefined behaviour (such as using misaligned or null pointer, conversion to, from, or between floating-point types which would overflow the destination, division by zero, etc)<br />
* [https://clang.llvm.org/docs/MemorySanitizer.html MemorySanitizer] for detecting reading uninitialised memory<br />
* [https://clang.llvm.org/docs/ThreadSanitizer.html ThreadSanitizer] for detecting threading issues<br />
<br />
To use the sanitisers, set the <code>USE_SANITIZER</code> CMake variable to one or several variables (separate by comma): <code>Address</code>, <code>Memory</code>, <code>MemoryWithOrigins</code>, <code>Undefined</code>, <code>Thread</code>, or <code>Leak</code><br />
<br />
To use them in Qt creator, head to <code>Projects</code> - <code>Build</code>: <br />
<br />
[[File:Sanitisers in qt creator.png|frameless|890x890px]]<br />
<br />
Not all sanitisers can be used with each other - in that case the cmake configuration won't allow you to continue.<br />
<br />
==Clang Format==<br />
Ensure that Qt Creator is set to use the <code>.clang-format</code> formatting style in the C++ settings. Turn on <code>Format instead of indenting</code> for <code>Ctrl+I</code> to format code, and ensure <code>Override Clang Format configuration file</code> is disabled:<br />
<br />
[[File:Qt Creator clang format.png]]<br />
<br />
This helps keep the look'n'feel of the source code in a consistent manner, even with many people contributing to Mudlet.<br />
<br />
<br />
=Building with multiple versions of Lua=<br />
Mudlet uses Lua 5.1 only, so if you are compiling on a system that also has later versions installed, you might get the following error: <code>‘LUA_GLOBALSINDEX’ was not declared in this scope</code>.<br />
<br />
To fix this, pass the path to Lua headers explicitly. For CMake: <code>-DLUA_INCLUDE_DIR=/usr/include/lua5.1</code> (adjust as needed).<br />
<br />
= Compile Time Flags =<br />
<br />
<nowiki><br />
DEBUG_UTF8_PROCESSING - for decoding the UTF-8 (1 byte with the MSB set or 2, 3 or 4 bytes) encoding<br />
DEBUG_GB_PROCESSING - for decoding the GBK (2 bytes) or GB18030 (2 or 4 bytes) encodiing<br />
DEBUG_BIG5_PROCESSING - for decoding the Big5-ETEN or Big5-HKSCS encodings<br />
DEBUG_EUC_KR_PROCESSING - for decoding the EUC_KR encoding<br />
DEBUG_SGR_PROCESSING - decoding the <ESC>[ codes (that pair of bytes being the CSI "Control Sequence Introducer" - including the one ending in m which is the "Set Graphics Rendition" that Mudlet (and other MUD clients and other things) use to control colours and other font effects.<br />
DEBUG_OSC_PROCESSING - decode the <ESC>] codes (that MUST end with a <ESC>\) - currently Mudlet only handles a couple of these OSC "Operating System Commands".<br />
DEBUG_MXP_PROCESSING - stuff to do with the MXP protocol - which uses a <ESC> ... z sequence of characters to do some things...<br />
</nowiki></div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20713Area 512024-01-05T12:21:53Z<p>Tamarindo: /* Mud New-Environ Standard Client Environment Variables MNES */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
!Available<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|Future<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|Future<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|4.18<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|4.18<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) INFO (2) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20712Area 512024-01-05T12:13:48Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
==sendSocket revised in PR #7066 (Open)==<br />
<br />
;sendSocket(data)<br />
<br />
: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.<br />
<br />
; success = sendSocket("data")<br />
<br />
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]<br />
<br />
{{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()]].<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''data:''<br />
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.<br />
<br />
;Returns <br />
* (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = function(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
==feedTelnet added in PR #7066 (Open)====<br />
<br />
; feedTelnet(data)<br />
<br />
: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.<br />
<br />
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]<br />
<br />
{{MudletVersion|tbd}}<br />
<br />
{{note}} This is not really intended for end-user's but might be useful in some circumstances.<br />
<br />
;Parameters<br />
* ''data''<br />
: 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.<br />
<br />
;Returns <br />
* 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.<br />
<br />
{| class="wikitable sortable"<br />
|+ Token value table<br />
|-<br />
! Token !! Byte !! Version!! Notes<br />
|-<br />
|| <00> || \0x00 || 1 || 0 dec.<br />
|-<br />
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary<br />
|-<br />
|| <NUL> || \0x00 || 1 || ASCII control character: NULL<br />
|-<br />
|| <01> || \x01 || 1 || 1 dec.<br />
|-<br />
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo<br />
|-<br />
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading<br />
|-<br />
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect<br />
|-<br />
|| <STX> || \x02 || 1 || ASCII control character: Start of Text<br />
|-<br />
|| <03> || \x03 || 1 || 3 dec.<br />
|-<br />
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead<br />
|-<br />
|| <ETX> || \x03 || 1 || ASCII control character: End of Text<br />
|-<br />
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation<br />
|-<br />
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission<br />
|-<br />
|| <05> || \x05 || 1 || <br />
|-<br />
|| <O_STATUS> || \x05 || 1 ||<br />
|-<br />
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry<br />
|-<br />
|| <06> || \x06 || 1 || Telnet option: Timing Mark<br />
|-<br />
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge<br />
|-<br />
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo<br />
|-<br />
|| <BELL> || \x07 || 1 || ASCII control character: Bell<br />
|-<br />
|| <08> || \x08 || 1 || Telnet option: Output Line Width<br />
|-<br />
|| <BS> || \x08 || 1 ||<br />
|-<br />
|| <09> || \x09 || 1 || Telnet option: Output Page Size<br />
|-<br />
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab<br />
|-<br />
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition<br />
|-<br />
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed<br />
|-<br />
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops<br />
|-<br />
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab<br />
|-<br />
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition<br />
|-<br />
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed<br />
|-<br />
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition<br />
|-<br />
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return<br />
|-<br />
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops<br />
|-<br />
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out<br />
|-<br />
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition<br />
|-<br />
|| <SI> || \x0f || 1 || ASCII control character: Shift-In<br />
|-<br />
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition<br />
|-<br />
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape<br />
|-<br />
|| <11> || \x11 || 1 || Telnet option: Extended ASCII<br />
|-<br />
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1<br />
|-<br />
|| <12> || \x12 || 1 || Telnet option: Logout<br />
|-<br />
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2<br />
|-<br />
|| <13> || \x13 || 1 || Telnet option: Byte Macro<br />
|-<br />
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3<br />
|-<br />
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal<br />
|-<br />
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4<br />
|-<br />
|| <15> || \x15 || 1 || Telnet option: SUPDUP<br />
|-<br />
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge<br />
|-<br />
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output<br />
|-<br />
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle<br />
|-<br />
|| <17> || \x17 || 1 || Telnet option: Send location<br />
|-<br />
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block<br />
|-<br />
|| <18> || \x18 || 1 ||<br />
|-<br />
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type<br />
|-<br />
|| <CAN> || \x18 || 1 || ASCII control character: Cancel<br />
|-<br />
|| <19> || \x19 || 1 ||<br />
|-<br />
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record<br />
|-<br />
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium<br />
|-<br />
|| <1A> || \x1a || 1 || Telnet option: TACACS User Identification<br />
|-<br />
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute<br />
|-<br />
|| <1B> || \x1b || 1 || Telnet option: Output Marking<br />
|-<br />
|| <ESC> || \x1b || 1 || ASCII control character: Escape<br />
|-<br />
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number<br />
|-<br />
|| <FS> || \x1c || 1 || ASCII control character: File Separator<br />
|-<br />
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime<br />
|-<br />
|| <GS> || \x1d || 1 || ASCII control character: Group Separator<br />
|-<br />
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD<br />
|-<br />
|| <RS> || \x1e || 1 || ASCII control character: Record Separator<br />
|-<br />
|| <1F> || \x1f || 1 ||<br />
|-<br />
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size<br />
|-<br />
|| <US> || \x1f || 1 || ASCII control character: Unit Separator<br />
|-<br />
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space<br />
|-<br />
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)<br />
|-<br />
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set<br />
|-<br />
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit<br />
|-<br />
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol<br />
|-<br />
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol<br />
|-<br />
|| <O_MCCP> || \x55 || 1 || 85 dec<br />
|-<br />
|| <O_MCCP2> || \x56 || 1 || 86 dec<br />
|-<br />
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol<br />
|-<br />
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol<br />
|-<br />
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol<br />
|-<br />
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol<br />
|-<br />
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete<br />
|-<br />
|| <O_ATCP> || \xc8 || 1 || 200 dec<br />
|-<br />
|| <O_GMCP> || \xc9 || 1 || 201 dec<br />
|-<br />
|| <T_EOR> || \xef || 1 || 239 dec<br />
|-<br />
|| <F0> || \xf0 || 1 ||<br />
|-<br />
|| <T_SE> || \xf0 || 1 ||<br />
|-<br />
|| <F1> || \xf1 || 1 ||<br />
|-<br />
|| <T_NOP> || \xf1 || 1 ||<br />
|-<br />
|| <F2> || \xf2 || 1 ||<br />
|-<br />
|| <T_DM> || \xf2 || 1 ||<br />
|-<br />
|| <F3> || \xf3 || 1 ||<br />
|-<br />
|| <T_BRK> || \xf3 || 1 ||<br />
|-<br />
|| <F4> || \xf4 || 1 ||<br />
|-<br />
|| <T_IP> || \xf4 || 1 ||<br />
|-<br />
|| <F5> || \xf5 || 1 ||<br />
|-<br />
|| <T_ABOP> || \xf5 || 1 ||<br />
|-<br />
|| <F6> || \xf6 || 1 ||<br />
|-<br />
|| <T_AYT> || \xf6 || 1 ||<br />
|-<br />
|| <F7> || \xf7 || 1 ||<br />
|-<br />
|| <T_EC> || \xf7 || 1 ||<br />
|-<br />
|| <F8> || \xf8 || 1 ||<br />
|-<br />
|| <T_EL> || \xf8 || 1 ||<br />
|-<br />
|| <F9> || \xf9 || 1 ||<br />
|-<br />
|| <T_GA> || \xf9 || 1 ||<br />
|-<br />
|| <FA> || \xfa || 1 ||<br />
|-<br />
|| <T_SB> || \xfa || 1 ||<br />
|-<br />
|| <FB> || \xfb || 1 ||<br />
|-<br />
|| <T_WILL> || \xfb || 1 ||<br />
|-<br />
|| <FC> || \xfc || 1 ||<br />
|-<br />
|| <T_WONT> || \xfc || 1 ||<br />
|-<br />
|| <FD> || \xfd || 1 ||<br />
|-<br />
|| <T_DO> || \xfd || 1 ||<br />
|-<br />
|| <FE> || \xfe || 1 ||<br />
|-<br />
|| <T_DONT> || \xfe || 1 ||<br />
|-<br />
|| <FF> || \xff || 1 ||<br />
|-<br />
|| <T_IAC> || \xff'<br />
|}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- 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!<br />
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.<br />
-- comments up top should introduce / explain what it does<br />
<br />
local something = feedTelnet(exampleValue)<br />
if something then<br />
-- do something with something (assuming there is a meaningful return value)<br />
end<br />
<br />
-- maybe another example for the optional second case<br />
local somethingElse = function(exampleValue, anotherValue)<br />
<br />
-- lastly, include an example with error handling to give an idea of good practice<br />
local ok, err = function()<br />
if not ok then<br />
debugc(f"Error: unable to do <particular thing> because {err}\n")<br />
return<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
-- This function is still being written up.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR #6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6946==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1, 0<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1, 0<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1, 0<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1, 0<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1, 0<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to five client environment variables ("IPADDRESS" will not be implemented in Mudlet). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
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, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20709Area 512024-01-04T12:49:34Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|0<br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|0<br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Manual:GMCP_Extensions&diff=20704Manual:GMCP Extensions2024-01-03T00:21:56Z<p>Tamarindo: </p>
<hr />
<div>{{TOC right}}<br />
= Automatic package installation =<br />
Mudlet supports automatic download and setup of [[Mudlet_Packages|Mudlet packages]] should the MUD server offer it. These packages could consist of graphical additions to your game or anything else you'd like your players to have loaded on their Mudlet profiles by default. This setup is automatic and carefree on part of the user, and handles package updates in a transparent manner as well.<br />
<br />
== setup ==<br />
After GMCP is negotiated, the server should send a message via GMCP with:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.GUI {<br />
"version": "<package version>",<br />
"url": "<url>"<br />
}<br />
</syntaxhighlight><br />
<br />
When Mudlet receives the message, it will do everything necessary to make the latest UI appear: if the user does not have a package, it will be downloaded and installed from the ''<url>'', and if they do, but of an older version - it'll be upgraded. If they're already on the latest, nothing happens. <br />
<br />
Ensure that the filename is the same as the package name, as Mudlet will use the filename in determining if the package is already installed.<br />
<br />
For example:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.GUI {<br />
"version": "39",<br />
"url": "http://www.stickmud.com/mudwww/StickMUD.mpackage"<br />
}<br />
</syntaxhighlight><br />
{{Note}} Mudlet 4.18+ The JSON "''version"'' parameter may also be an integer value<br />
<br />
{{Note}} there is an older, not preferred but still supported way is to send a message via GMCP with:<br />
<br />
Client.GUI <package version>\n<url><br />
<br />
== demonstration ==<br />
Enable GMCP in settings, connect to Midnight Sun 2 (''midnightsun2.org'' on port ''3000'') and create a character. A GUI will automatically install over GMCP once you finish character creation, and an overview of it is [http://midnightsun2.org/gateways/gui.html?show=overview available here] - a good idea to consider to make your MUD more visually appealing.<br />
<br />
For an ATCP demo, connect to ''godwars2.org'' on port ''3000''. Mudlet will download the GW2 interface and set it up automatically.<br />
<br />
Sample string sent by GodWars 2:<br />
<br />
"Client.GUI 1\nhttp://www.godwars2.org/download/mudlet/GW2_GUI.mpackage"<br />
<br />
== updating ==<br />
If you change the package version to any other text than what it previously was, Mudlet will consider it an update - it'll uninstall the old package and install the new package. This happens without prompting the user (since it can be kind of tricky if they decline), thus any modifications they would have done would be wiped - encourage users to make any modifications outside of the package and provide hooks for doing so.<br />
<br />
For [https://en.wikipedia.org/wiki/Software_versioning#Schemes package versioning] you can use any text you seem appropriate. Simple version numbers (start with 1, then 2, then 3) will do, as well as minor and/or patch versions like 1.2 and 1.2.3 or even 1.2.3-alpha (see https://semver.org/ for inspiration). You could also easily use the current date of release (like 2021-06-17 now - but make sure to indicate if you happen to release multiple versions on the same day), or even fancy special names for each release (how about http://sentimentalversioning.org/ for inspiration?)<br />
<br />
= Automatic map download =<br />
Mudlet can download a map for the user as soon they open the mapper for the first time, as well as re-download the map from the Mapper tab in settings:<br />
<br />
[[File:Start own map.png|center]]<br />
<br />
The map can be either in the [[Standards:MMP|MMP standard]] (indicated by .xml at end of file name) or one [[Manual:Mapper_Functions#saveMap|exported from Mudlet]].<br />
<br />
== setup ==<br />
To let Mudlet know where it can download your map, send the following after GMCP has been enabled:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Map {<br />
"url": "https://..."<br />
}<br />
</syntaxhighlight></div>Tamarindohttps://wiki.mudlet.org/index.php?title=Manual:GMCP_Extensions&diff=20703Manual:GMCP Extensions2024-01-03T00:20:34Z<p>Tamarindo: </p>
<hr />
<div>{{TOC right}}<br />
= Automatic package installation =<br />
Mudlet supports automatic download and setup of [[Mudlet_Packages|Mudlet packages]] should the MUD server offer it. These packages could consist of graphical additions to your game or anything else you'd like your players to have loaded on their Mudlet profiles by default. This setup is automatic and carefree on part of the user, and handles package updates in a transparent manner as well.<br />
<br />
== setup ==<br />
After GMCP is negotiated, the server should send a message via GMCP with:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.GUI {<br />
"version": "<package version>",<br />
"url": "<url>"<br />
}<br />
</syntaxhighlight><br />
<br />
When Mudlet receives the message, it will do everything necessary to make the latest UI appear: if the user does not have a package, it will be downloaded and installed from the ''<url>'', and if they do, but of an older version - it'll be upgraded. If they're already on the latest, nothing happens. <br />
<br />
Ensure that the filename is the same as the package name, as Mudlet will use the filename in determining if the package is already installed.<br />
<br />
For example:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.GUI {<br />
"version": "39",<br />
"url": "http://www.stickmud.com/mudwww/StickMUD.mpackage"<br />
}<br />
</syntaxhighlight><br />
{{Note}} The JSON ''version'' may also be an integer value with Mudlet 4.18+<br />
<br />
{{Note}} there is an older, not preferred but still supported way is to send a message via GMCP with:<br />
<br />
Client.GUI <package version>\n<url><br />
<br />
== demonstration ==<br />
Enable GMCP in settings, connect to Midnight Sun 2 (''midnightsun2.org'' on port ''3000'') and create a character. A GUI will automatically install over GMCP once you finish character creation, and an overview of it is [http://midnightsun2.org/gateways/gui.html?show=overview available here] - a good idea to consider to make your MUD more visually appealing.<br />
<br />
For an ATCP demo, connect to ''godwars2.org'' on port ''3000''. Mudlet will download the GW2 interface and set it up automatically.<br />
<br />
Sample string sent by GodWars 2:<br />
<br />
"Client.GUI 1\nhttp://www.godwars2.org/download/mudlet/GW2_GUI.mpackage"<br />
<br />
== updating ==<br />
If you change the package version to any other text than what it previously was, Mudlet will consider it an update - it'll uninstall the old package and install the new package. This happens without prompting the user (since it can be kind of tricky if they decline), thus any modifications they would have done would be wiped - encourage users to make any modifications outside of the package and provide hooks for doing so.<br />
<br />
For [https://en.wikipedia.org/wiki/Software_versioning#Schemes package versioning] you can use any text you seem appropriate. Simple version numbers (start with 1, then 2, then 3) will do, as well as minor and/or patch versions like 1.2 and 1.2.3 or even 1.2.3-alpha (see https://semver.org/ for inspiration). You could also easily use the current date of release (like 2021-06-17 now - but make sure to indicate if you happen to release multiple versions on the same day), or even fancy special names for each release (how about http://sentimentalversioning.org/ for inspiration?)<br />
<br />
= Automatic map download =<br />
Mudlet can download a map for the user as soon they open the mapper for the first time, as well as re-download the map from the Mapper tab in settings:<br />
<br />
[[File:Start own map.png|center]]<br />
<br />
The map can be either in the [[Standards:MMP|MMP standard]] (indicated by .xml at end of file name) or one [[Manual:Mapper_Functions#saveMap|exported from Mudlet]].<br />
<br />
== setup ==<br />
To let Mudlet know where it can download your map, send the following after GMCP has been enabled:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Map {<br />
"url": "https://..."<br />
}<br />
</syntaxhighlight></div>Tamarindohttps://wiki.mudlet.org/index.php?title=Manual:GMCP_Extensions&diff=20702Manual:GMCP Extensions2024-01-03T00:20:15Z<p>Tamarindo: </p>
<hr />
<div>{{TOC right}}<br />
= Automatic package installation =<br />
Mudlet supports automatic download and setup of [[Mudlet_Packages|Mudlet packages]] should the MUD server offer it. These packages could consist of graphical additions to your game or anything else you'd like your players to have loaded on their Mudlet profiles by default. This setup is automatic and carefree on part of the user, and handles package updates in a transparent manner as well.<br />
<br />
== setup ==<br />
After GMCP is negotiated, the server should send a message via GMCP with:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.GUI {<br />
"version": "<package version>",<br />
"url": "<url>"<br />
}<br />
</syntaxhighlight><br />
<br />
When Mudlet receives the message, it will do everything necessary to make the latest UI appear: if the user does not have a package, it will be downloaded and installed from the ''<url>'', and if they do, but of an older version - it'll be upgraded. If they're already on the latest, nothing happens. <br />
<br />
Ensure that the filename is the same as the package name, as Mudlet will use the filename in determining if the package is already installed.<br />
<br />
For example:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.GUI {<br />
"version": "39",<br />
"url": "http://www.stickmud.com/mudwww/StickMUD.mpackage"<br />
}<br />
</syntaxhighlight><br />
{{Note}} The JSON ''version'' may also be an integer value with Mudlet 4.18+<br />
{{Note}} there is an older, not preferred but still supported way is to send a message via GMCP with:<br />
<br />
Client.GUI <package version>\n<url><br />
<br />
== demonstration ==<br />
Enable GMCP in settings, connect to Midnight Sun 2 (''midnightsun2.org'' on port ''3000'') and create a character. A GUI will automatically install over GMCP once you finish character creation, and an overview of it is [http://midnightsun2.org/gateways/gui.html?show=overview available here] - a good idea to consider to make your MUD more visually appealing.<br />
<br />
For an ATCP demo, connect to ''godwars2.org'' on port ''3000''. Mudlet will download the GW2 interface and set it up automatically.<br />
<br />
Sample string sent by GodWars 2:<br />
<br />
"Client.GUI 1\nhttp://www.godwars2.org/download/mudlet/GW2_GUI.mpackage"<br />
<br />
== updating ==<br />
If you change the package version to any other text than what it previously was, Mudlet will consider it an update - it'll uninstall the old package and install the new package. This happens without prompting the user (since it can be kind of tricky if they decline), thus any modifications they would have done would be wiped - encourage users to make any modifications outside of the package and provide hooks for doing so.<br />
<br />
For [https://en.wikipedia.org/wiki/Software_versioning#Schemes package versioning] you can use any text you seem appropriate. Simple version numbers (start with 1, then 2, then 3) will do, as well as minor and/or patch versions like 1.2 and 1.2.3 or even 1.2.3-alpha (see https://semver.org/ for inspiration). You could also easily use the current date of release (like 2021-06-17 now - but make sure to indicate if you happen to release multiple versions on the same day), or even fancy special names for each release (how about http://sentimentalversioning.org/ for inspiration?)<br />
<br />
= Automatic map download =<br />
Mudlet can download a map for the user as soon they open the mapper for the first time, as well as re-download the map from the Mapper tab in settings:<br />
<br />
[[File:Start own map.png|center]]<br />
<br />
The map can be either in the [[Standards:MMP|MMP standard]] (indicated by .xml at end of file name) or one [[Manual:Mapper_Functions#saveMap|exported from Mudlet]].<br />
<br />
== setup ==<br />
To let Mudlet know where it can download your map, send the following after GMCP has been enabled:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Map {<br />
"url": "https://..."<br />
}<br />
</syntaxhighlight></div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20701Area 512024-01-03T00:03:03Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!OPT-IN<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|Yes<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|Yes<br />
|<br />
| Character name defined in logon dialogue.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20699Area 512024-01-01T20:05:27Z<p>Tamarindo: /* Negotiating MTTS */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20698Area 512024-01-01T20:04:24Z<p>Tamarindo: /* Available MTTS Information */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports Transport Layer Security for data encryption.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20697Area 512024-01-01T19:58:58Z<p>Tamarindo: /* Negotiating NEW-ENVIRON */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20696Area 512024-01-01T19:56:15Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20695Area 512024-01-01T19:49:47Z<p>Tamarindo: /* Screen Reader Opt-In */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
<br />
[[File:Screenshot_2024-01-01_at_2.35.07_PM.png|alt=Image displaying the Advertise screen reader checkbox|619x619px]]<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20694Area 512024-01-01T19:48:56Z<p>Tamarindo: /* Activating MNES */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
<br />
[[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;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
[[File:Screenshot 2024-01-01 at 2.35.07 PM.png|alt=Image displaying the Advertise screen reader checkbox|left|619x619px]]<br />
<br />
<br />
<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20693Area 512024-01-01T19:47:54Z<p>Tamarindo: /* Activating MNES */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
&nbsp;<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
[[File:Screenshot 2024-01-01 at 2.35.07 PM.png|alt=Image displaying the Advertise screen reader checkbox|left|619x619px]]<br />
<br />
<br />
<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20692Area 512024-01-01T19:47:01Z<p>Tamarindo: /* Activating MNES */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
[[File:Screenshot 2024-01-01 at 2.35.07 PM.png|alt=Image displaying the Advertise screen reader checkbox|left|619x619px]]<br />
<br />
<br />
<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20691Area 512024-01-01T19:40:29Z<p>Tamarindo: /* Negotiating MTTS */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
* '''Support for ANSI Color Codes:''' The client supports all common ANSI color codes.<br />
* '''UTF-8 Character Encoding:''' The client utilizes UTF-8 character encoding.<br />
* '''Support for 256 Color Codes:''' Mudlet is equipped to handle all 256 color codes.<br />
* '''OSC Color Palette:''' Mudlet acknowledges support for the OSC color palette.<br />
* '''Screen Reader Support:''' Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
* '''Truecolor Codes:''' Mudlet supports truecolor codes using semicolon notation.<br />
* '''Mud New Environment Standard (MNES) Support:''' The client adheres to the Mud New Environment Standard for information exchange.<br />
* '''TLS Encryption:''' The client supports Transport Layer Security for data encryption.<br />
<br />
==== Screen Reader Opt-In ====<br />
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.<br />
[[File:Screenshot 2024-01-01 at 2.35.07 PM.png|alt=Image displaying the Advertise screen reader checkbox|left|619x619px]]<br />
<br />
<br />
<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Per the MTTS guidance, game servers should initiate up to 4 TTYPE requests to complete the TTYPE cycling routine. Reference the [https://tintin.mudhalla.net/protocols/mtts/ MTTS website] for more information.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=File:Screenshot_2024-01-01_at_2.35.07_PM.png&diff=20690File:Screenshot 2024-01-01 at 2.35.07 PM.png2024-01-01T19:36:00Z<p>Tamarindo: </p>
<hr />
<div>Screen Reader Opt-In</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20689Area 512024-01-01T19:26:53Z<p>Tamarindo: /* Negotiating MTTS */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
1. **Negotiation of MTTS:** Mudlet responds to server prompts for MTTS, indicating support for various features.<br />
<br />
2. **Support for ANSI Color Codes:** The client supports all common ANSI color codes.<br />
<br />
4. **UTF-8 Character Encoding:** The client utilizes UTF-8 character encoding.<br />
<br />
5. **Support for 256 Color Codes:** Mudlet is equipped to handle all 256 color codes.<br />
<br />
7. **OSC Color Palette:** Mudlet acknowledges support for the OSC color palette.<br />
<br />
8. **Screen Reader Support:** Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
<br />
10. **Truecolor Codes:** Mudlet supports truecolor codes using semicolon notation.<br />
<br />
11. **Mud New Environment Standard (MNES) Support:** The client adheres to the Mud New Environment Standard for information exchange.<br />
<br />
13. **TLS Encryption:** The client supports Transport Layer Security for data encryption.<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20688Area 512024-01-01T19:26:36Z<p>Tamarindo: /* Negotiating MTTS */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
1. **Negotiation of MTTS:** Mudlet responds to server prompts for MTTS, indicating support for various features.<br />
<br />
2. **Support for ANSI Color Codes:** The client supports all common ANSI color codes.<br />
<br />
4. **UTF-8 Character Encoding:** The client utilizes UTF-8 character encoding.<br />
<br />
5. **Support for 256 Color Codes:** Mudlet is equipped to handle all 256 color codes.<br />
<br />
7. **OSC Color Palette:** Mudlet acknowledges support for the OSC color palette.<br />
<br />
8. **Screen Reader Support:** Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
<br />
10. **Truecolor Codes:** Mudlet supports truecolor codes using semicolon notation.<br />
<br />
11. **Mud New Environment Standard (MNES) Support:** The client adheres to the Mud New Environment Standard for information exchange.<br />
<br />
13. **TLS Encryption:** The client supports Transport Layer Security for data encryption.<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|IAC SB TTYPE (24) SEND (1) IAC SE<br />
|IAC SB TTYPE (24) IS (0) ''MTTS 2349'' IAC SE<br />
|-<br />
|}<br />
<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20687Area 512024-01-01T19:25:01Z<p>Tamarindo: /* Negotiating MTTS */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
1. **Negotiation of MTTS:** Mudlet responds to server prompts for MTTS, indicating support for various features.<br />
<br />
2. **Support for ANSI Color Codes:** The client supports all common ANSI color codes.<br />
<br />
4. **UTF-8 Character Encoding:** The client utilizes UTF-8 character encoding.<br />
<br />
5. **Support for 256 Color Codes:** Mudlet is equipped to handle all 256 color codes.<br />
<br />
7. **OSC Color Palette:** Mudlet acknowledges support for the OSC color palette.<br />
<br />
8. **Screen Reader Support:** Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
<br />
10. **Truecolor Codes:** Mudlet supports truecolor codes using semicolon notation.<br />
<br />
11. **Mud New Environment Standard (MNES) Support:** The client adheres to the Mud New Environment Standard for information exchange.<br />
<br />
13. **TLS Encryption:** The client supports Transport Layer Security for data encryption.<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|}<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20686Area 512024-01-01T19:23:20Z<p>Tamarindo: /* Negotiating MTTS */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
1. **Negotiation of MTTS:** Mudlet responds to server prompts for MTTS, indicating support for various features.<br />
<br />
2. **Support for ANSI Color Codes:** The client supports all common ANSI color codes.<br />
<br />
4. **UTF-8 Character Encoding:** The client utilizes UTF-8 character encoding.<br />
<br />
5. **Support for 256 Color Codes:** Mudlet is equipped to handle all 256 color codes.<br />
<br />
7. **OSC Color Palette:** Mudlet acknowledges support for the OSC color palette.<br />
<br />
8. **Screen Reader Support:** Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
<br />
10. **Truecolor Codes:** Mudlet supports truecolor codes using semicolon notation.<br />
<br />
11. **Mud New Environment Standard (MNES) Support:** The client adheres to the Mud New Environment Standard for information exchange.<br />
<br />
13. **TLS Encryption:** The client supports Transport Layer Security for data encryption.<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO TTYPE (24) IAC SE<br />
| IAC WILL TTYPE (24) IAC SE<br />
|-<br />
| IAC SB TTYPE (24) SEND (1) IAC SE<br />
| IAC SB TTYPE (24) IS (0) ''MUDLET-4/18'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20685Area 512024-01-01T19:18:16Z<p>Tamarindo: /* Available MTTS Information */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
1. **Negotiation of MTTS:** Mudlet responds to server prompts for MTTS, indicating support for various features.<br />
<br />
2. **Support for ANSI Color Codes:** The client supports all common ANSI color codes.<br />
<br />
4. **UTF-8 Character Encoding:** The client utilizes UTF-8 character encoding.<br />
<br />
5. **Support for 256 Color Codes:** Mudlet is equipped to handle all 256 color codes.<br />
<br />
7. **OSC Color Palette:** Mudlet acknowledges support for the OSC color palette.<br />
<br />
8. **Screen Reader Support:** Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
<br />
10. **Truecolor Codes:** Mudlet supports truecolor codes using semicolon notation.<br />
<br />
11. **Mud New Environment Standard (MNES) Support:** The client adheres to the Mud New Environment Standard for information exchange.<br />
<br />
13. **TLS Encryption:** The client supports Transport Layer Security for data encryption.<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20684Area 512024-01-01T19:17:38Z<p>Tamarindo: /* MTTS, PR #7036 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
By incorporating the Mud Terminal-Type Standard (MTTS), Mudlet will communicate with interested servers that it possesses the following capabilities: <br />
<br />
1. **Negotiation of MTTS:** Mudlet responds to server prompts for MTTS, indicating support for various features.<br />
<br />
2. **Support for ANSI Color Codes:** The client supports all common ANSI color codes.<br />
<br />
4. **UTF-8 Character Encoding:** The client utilizes UTF-8 character encoding.<br />
<br />
5. **Support for 256 Color Codes:** Mudlet is equipped to handle all 256 color codes.<br />
<br />
7. **OSC Color Palette:** Mudlet acknowledges support for the OSC color palette.<br />
<br />
8. **Screen Reader Support:** Mudlet offers support for screen readers, with opt-in functionality (not advertised by default).<br />
<br />
10. **Truecolor Codes:** Mudlet supports truecolor codes using semicolon notation.<br />
<br />
11. **Mud New Environment Standard (MNES) Support:** The client adheres to the Mud New Environment Standard for information exchange.<br />
<br />
13. **TLS Encryption:** The client supports Transport Layer Security for data encryption.<br />
<br />
==== Available MTTS Information ====<br />
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.<br />
{| class="wikitable"<br />
|+MTTS Bitvector<br />
!Bit<br />
!Property<br />
!Meaning<br />
|-<br />
|1<br />
|ANSI<br />
|Client supports all common ANSI color codes.<br />
|-<br />
|2<br />
|VT100<br />
|Client supports all common VT100 codes.<br />
|-<br />
|4<br />
|UTF-8<br />
|Client is using UTF-8 character encoding.<br />
|-<br />
|8<br />
|256 COLORS<br />
|Client supports all 256 color codes.<br />
|-<br />
|16<br />
|MOUSE TRACKING<br />
|Client supports xterm mouse tracking.<br />
|-<br />
|32<br />
|OSC COLOR PALETTE<br />
|Client supports OSC and the OSC color palette.<br />
|-<br />
|64<br />
|SCREEN READER<br />
|Client is using a screen reader.<br />
|-<br />
|128<br />
|PROXY<br />
|Client is a proxy allowing different users to connect from the same IP address.<br />
|-<br />
|256<br />
|TRUECOLOR<br />
|Client supports truecolor codes using semicolon notation.<br />
|-<br />
|512<br />
|MNES<br />
|Client supports the Mud New Environment Standard for information exchange.<br />
|-<br />
|1024<br />
|MSLP<br />
|Client supports the Mud Server Link Protocol for clickable link handling.<br />
|-<br />
|2048<br />
|TLS<br />
|Client supports SSL for data encryption, preferably TLS 1.3 or higher.<br />
|}<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating MTTS====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20683Area 512024-01-01T18:53:28Z<p>Tamarindo: /* Negotiating MNES */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
MNES negotiation is available in Mudlet 4.18+.<br />
<br />
==MTTS, PR #7036==<br />
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.<br />
<br />
===MTTS in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available MTTS Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
<br />
MTTS is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20682Area 512024-01-01T18:46:42Z<p>Tamarindo: /* Supported Protocols, PR #7058 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MNES, MTTS, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20681Area 512024-01-01T18:45:56Z<p>Tamarindo: /* Negotiating NEW-ENVIRON */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND (1) IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT'' VAL (1) ''Bitstream Vera Sans Mono'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''FONT_SIZE'' VAL (1) ''14'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''SCREEN_READER'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''UTF-8'' VAL (1) ''1'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WONT NEW-ENVIRON (39) IAC SE<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
== MNES, PR #7058 ==<br />
The Mud New-Environment Standard is an alternative way to share client-supported details between Mudlet to game servers.<br />
<br />
==== Activating MNES ====<br />
If your game supports MNES, instruct users to toggle on the `Enable MNES` menu option on the General tab in Mudlet.<br />
[[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|left|614x614px|Enable MNES is found on the Game protocols section of the General tab of Settings]]<br />
<br />
<br />
<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to six 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
==== Negotiating MNES ====<br />
The primary differences between MNES and the out-of-the-box RFC 152 NEW-ENVIRON implementation is that MNES sends no more than 6 client environment variables, 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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39) IAC SE<br />
| IAC WILL NEW-ENVIRON (39) IAC SE<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_NAME'' VAL (1) ''MUDLET'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''CLIENT_VERSION'' VAL (1) ''4/17/2-DEV'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''IPADDRESS'' VAL (1) IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''MTTS'' VAL (1) ''2349'' IAC SE<br />
<br />
IAC SB NEW-ENVIRON (39) IS (0) VAR (0) ''TERMINAL_TYPE'' VAL (1) ''ANSI-TRUECOLOR'' IAC SE<br />
|-<br />
|<br />
|''[ As updates occur in the client the following are possible... ]''<br />
|-<br />
|<br />
|IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''CHARSET'' VAL (1) ''ASCII'' IAC SE<br />
IAC SB NEW-ENVIRON (39) INFO (2) VAR (0) ''MTTS'' VAL (1) ''2345'' IAC SE<br />
|-<br />
|}<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=File:Screenshot_2024-01-01_at_1.41.06_PM.png&diff=20680File:Screenshot 2024-01-01 at 1.41.06 PM.png2024-01-01T18:42:06Z<p>Tamarindo: </p>
<hr />
<div>Game protocols menu under the Settings, General menu in Mudlet</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20679Area 512024-01-01T18:12:51Z<p>Tamarindo: /* Mud New-Environ Standard Client Environment Variables MNES */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to size 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
Success example #1 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20678Area 512024-01-01T18:09:21Z<p>Tamarindo: /* Negotiating NEW-ENVIRON */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
==== Mud New-Environ Standard Client Environment Variables [https://tintin.mudhalla.net/protocols/mnes/ MNES] ====<br />
MNES leverages VAR (0) to transfer up to size 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| VAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| VAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| VAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| VAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| VAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
|}<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20677Area 512024-01-01T18:01:21Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| '''SYSTEMTYPE'''<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| '''USER'''<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| '''256_COLORS'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''ANSI'''<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''CHARSET'''<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| '''CLIENT_NAME'''<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| '''CLIENT_VERSION'''<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| '''FONT'''<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| '''FONT_SIZE'''<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| '''IPADDRESS'''<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''LANGUAGE'''<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| '''MOUSE_TRACKING'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''MTTS'''<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| '''OSC_COLOR_PALETTE'''<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''PROXY'''<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''SCREEN_READER'''<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TERMINAL_TYPE'''<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| '''TLS'''<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''TRUECOLOR'''<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''UTF-8'''<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| '''VT100'''<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| '''WORD_WRAP'''<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20676Area 512024-01-01T18:00:44Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
Two types of variables are used per RFC 152, well-known variables defines with VAR (0) and for less common variables, USERVAR (3). 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.<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Example Values<br />
!Mudlet Default<br />
!INFO<br />
! Purpose<br />
|-<br />
| VAR<br />
| SYSTEMTYPE<br />
| MACOS, WIN64, WIN32, BSD4, CYGWIN, FREEBSD, HURD, NETBSD, OPENBSD, LINUX, UNIX<br />
|<br />
|<br />
| Client runs within the listed operating system.<br />
|-<br />
| VAR<br />
| USER<br />
| tamarindo<br />
|<br />
|<br />
| Character name defined in logon dialogue. Do not use to authenticate a user to your game.<br />
|-<br />
| USERVAR<br />
| 256_COLORS<br />
| 1<br />
|1<br />
|<br />
| Client supports all 256 color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| ANSI<br />
| 1<br />
|1<br />
|<br />
| Client supports all common ANSI color codes. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| CHARSET<br />
| UTF-8, ASCII<br />
|<br />
|Yes<br />
| Encoding set in the client<br />
|-<br />
| USERVAR<br />
| CLIENT_NAME<br />
| MUDLET<br />
|MUDLET<br />
|<br />
| Name of the client.<br />
|-<br />
| USERVAR<br />
| CLIENT_VERSION<br />
| 4/18, 4/17/2-DEV<br />
|<br />
|<br />
| Version of the client.<br />
|-<br />
| USERVAR<br />
| FONT<br />
| Bitstream Vera Sans Mono<br />
|<br />
|Yes<br />
| Font used in the client.<br />
|-<br />
| USERVAR<br />
| FONT_SIZE<br />
| 14<br />
|<br />
|Yes<br />
| Font size used in the client.<br />
|-<br />
| USERVAR<br />
| IPADDRESS<br />
| 127.0.0.1<br />
|<empty><br />
|<br />
| Client's IP address. Proxies may report the client's real IP address. This allows a MUD to ban specific users without having to ban an entire proxy. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| LANGUAGE<br />
| en_US<br />
|<br />
|Yes<br />
| Client is using this language code and country variant.<br />
|-<br />
| USERVAR<br />
| MOUSE_TRACKING<br />
| 1<br />
|<empty><br />
|<br />
| Client supports xterm mouse tracking. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| MTTS<br />
| 2349<br />
|<br />
|Yes<br />
| Bitvector defined in the Mud Terminal Type Standard ([https://tintin.mudhalla.net/protocols/mtts/ MTTS]).<br />
|-<br />
| USERVAR<br />
| OSC_COLOR_PALETTE<br />
| 1<br />
|<br />
|<br />
| Client supports OSC and the OSC color palette. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| PROXY<br />
| 1<br />
|<empty><br />
|<br />
| Client is a proxy allowing different users to connect from the same IP address. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| SCREEN_READER<br />
| 1<br />
|<empty><br />
|Yes<br />
| Client is using a screen reader. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| TERMINAL_TYPE<br />
| ANSI-TRUECOLOR, ANSI-256COLOR, ANSI, XTERM, VT100, DUMB<br />
|ANSI-TRUECOLOR<br />
|<br />
| Terminal type of the client<br />
|-<br />
| USERVAR<br />
| TLS<br />
| 1<br />
|<br />
|<br />
| Client supports Transport Layer Security for data encryption. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| TRUECOLOR<br />
| 1<br />
|<br />
|<br />
| Client supports truecolor codes using semicolon notation. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| UTF-8<br />
| 1<br />
|<br />
|Yes<br />
| Client is using UTF-8 character encoding. 1 = Yes/True/ACK.<br />
|-<br />
| USERVAR<br />
| VT100<br />
| 1<br />
|<empty><br />
|<br />
| Client supports all common VT100 codes. 1 = Yes/True/ACK. This is not applicable for Mudlet and while defined, is not used.<br />
|-<br />
| USERVAR<br />
| WORD_WRAP<br />
| 100<br />
|<br />
|Yes<br />
| Client wraps text at this value<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20675Area 512024-01-01T17:06:08Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Value<br />
! Purpose<br />
|-<br />
| VAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| VAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20674Area 512024-01-01T17:04:31Z<p>Tamarindo: /* Available Client Environment Variables RFC 1572 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ====<br />
<br />
{| class="wikitable"<br />
! Type<br />
! Variable<br />
! Value<br />
! Purpose<br />
|-<br />
| USERVAL<br />
| CHARSET<br />
| UTF-8, ASCII<br />
| Encoding set in the client<br />
|-<br />
|}<br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20673Area 512024-01-01T17:00:39Z<p>Tamarindo: /* NEW-ENVIRON, PR #7058 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
==== Available Client Environment Variables [https://datatracker.ietf.org/doc/html/rfc1572 RFC 1572] ==== <br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20672Area 512024-01-01T16:55:11Z<p>Tamarindo: /* NEW-ENVIRON, PR #7058 */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
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.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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''', and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: '''Mud New-Environ Standard''', which shares a standardized set of client information across multiple clients. <br />
<br />
====Client Environment Variable Updates====<br />
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. <br />
<br />
====Negotiating NEW-ENVIRON====<br />
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.<br />
<br />
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>"]. 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.<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20671Area 512024-01-01T16:38:32Z<p>Tamarindo: /* Automated Updates */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
To enhance the player experience by sharing more client-supported details, the Telnet New-Environ Option may be used to transfer detail from Mudlet to game servers. Sharing supporting information on encoding, terminal emulation, and accessibility aims to ease initial player setup and increase the retention rate for new gaming community members.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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, and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: Mud New-Environ Standard, which shares a specific set of client information. <br />
<br />
====Manual Environment Updates====<br />
Mudlet supports manual selection of a number of options that may dynamically inform servers that have sent interest in knowing about these client environmental variables after negotiating the NEW-ENVIRON option. For example, when a Mudlet user update the server data encoding for a profile by choosing Settings, General and selecting a server data encoding from the corresponding drop-down menu, this information is available for transfer via both the RFC (default) and MNES (needs enabled by the user) options. <br />
<br />
====Automated Updates====<br />
Negotiating the '''NEW-ENVIRON''' telnet option provides game servers the capability to request one, multiple, or all client environment variables set within Mudlet. Game servers may send a telopt DO NEW-ENVIRON (39), Mudlet responds with a WILL NEW-ENVIRON (39), then the game server may send SB NEW-ENVIRON (39) SEND to receive all available environment variables. Mudlet will respond 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 sent to a server within the current connection, Mudlet will respond with SB NEW-ENVIRON (39) INFO (2) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] to which no reply from the server is needed. It is possible to send a specific list of requested environmental variables to Mudlet with the format SB NEW-ENVIRON (39) SEND < VAR (0) | USERVAR (3) > "<variable>" [ .. < VAR (0) | USERVAR (3) > "<variable>" ].<br />
<br />
Success example #1 (one environmental variable):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
Success example #2 (all environmental variables):<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS 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) ''IPADDRESS'' VAL (1) USERVAR (3) ''LANGUAGE'' VAL (1) ''en_US'' USERVAR (3) ''MOUSE_TRACKING'' VAL (1) USERVAR (3) ''MTTS'' VAL (1) ''2349'' USERVAR (3) ''OSC_COLOR_PALETTE'' VAL (1) ''1'' USERVAR (3) ''PROXY'' VAL (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) USERVAR (3) ''WORD_WRAP'' VAL (1) ''100''<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20670Area 512024-01-01T16:25:44Z<p>Tamarindo: /* Automated Updates */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
To enhance the player experience by sharing more client-supported details, the Telnet New-Environ Option may be used to transfer detail from Mudlet to game servers. Sharing supporting information on encoding, terminal emulation, and accessibility aims to ease initial player setup and increase the retention rate for new gaming community members.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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, and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: Mud New-Environ Standard, which shares a specific set of client information. <br />
<br />
====Manual Environment Updates====<br />
Mudlet supports manual selection of a number of options that may dynamically inform servers that have sent interest in knowing about these client environmental variables after negotiating the NEW-ENVIRON option. For example, when a Mudlet user update the server data encoding for a profile by choosing Settings, General and selecting a server data encoding from the corresponding drop-down menu, this information is available for transfer via both the RFC (default) and MNES (needs enabled by the user) options. <br />
<br />
====Automated Updates====<br />
Negotiating the '''NEW-ENVIRON''' telnet option provides game servers the capability to request one, multiple, or all client environment variables set within Mudlet. Game servers may send a telopt DO NEW-ENVIRON (39), Mudlet responds with a WILL NEW-ENVIRON (39), then the game server may send SB NEW-ENVIRON (39) SEND to receive all available environment variables. Mudlet will respond 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 sent to a server within the current connection, Mudlet will respond with SB NEW-ENVIRON (39) INFO (2) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] to which no reply from the server is needed. It is possible to send a specific list of requested environmental variables to Mudlet with the format SB NEW-ENVIRON (39) SEND < VAR (0) | USERVAR (3) > "<variable>" [ .. < VAR (0) | USERVAR (3) > "<variable>" ].<br />
<br />
Success example:<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WILL NEW-ENVIRON (39)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20669Area 512024-01-01T16:25:01Z<p>Tamarindo: /* Automated Updates */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
To enhance the player experience by sharing more client-supported details, the Telnet New-Environ Option may be used to transfer detail from Mudlet to game servers. Sharing supporting information on encoding, terminal emulation, and accessibility aims to ease initial player setup and increase the retention rate for new gaming community members.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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, and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: Mud New-Environ Standard, which shares a specific set of client information. <br />
<br />
====Manual Environment Updates====<br />
Mudlet supports manual selection of a number of options that may dynamically inform servers that have sent interest in knowing about these client environmental variables after negotiating the NEW-ENVIRON option. For example, when a Mudlet user update the server data encoding for a profile by choosing Settings, General and selecting a server data encoding from the corresponding drop-down menu, this information is available for transfer via both the RFC (default) and MNES (needs enabled by the user) options. <br />
<br />
====Automated Updates====<br />
Negotiating the '''NEW-ENVIRON''' telnet option provides game servers the capability to request one, multiple, or all client environment variables set within Mudlet. Game servers may send a telopt DO NEW-ENVIRON (39), Mudlet responds with a WILL NEW-ENVIRON (39), then the game server may send SB NEW-ENVIRON (39) SEND to receive all available environment variables. Mudlet will respond 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 sent to a server within the current connection, Mudlet will respond with SB NEW-ENVIRON (39) INFO (2) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] to which no reply from the server is needed. It is possible to send a specific list of requested environmental variables to Mudlet with the format SB NEW-ENVIRON (39) SEND < VAR (0) | USERVAR (3) > "<variable>" [ .. < VAR (0) | USERVAR (3) > "<variable>" ].<br />
<br />
Success example:<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO CHARSET (42)<br />
| IAC WILL CHARSET (42)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC DO NEW-ENVIRON (39)<br />
| IAC WONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20668Area 512024-01-01T16:01:31Z<p>Tamarindo: /* Automated Updates */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
To enhance the player experience by sharing more client-supported details, the Telnet New-Environ Option may be used to transfer detail from Mudlet to game servers. Sharing supporting information on encoding, terminal emulation, and accessibility aims to ease initial player setup and increase the retention rate for new gaming community members.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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, and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: Mud New-Environ Standard, which shares a specific set of client information. <br />
<br />
====Manual Environment Updates====<br />
Mudlet supports manual selection of a number of options that may dynamically inform servers that have sent interest in knowing about these client environmental variables after negotiating the NEW-ENVIRON option. For example, when a Mudlet user update the server data encoding for a profile by choosing Settings, General and selecting a server data encoding from the corresponding drop-down menu, this information is available for transfer via both the RFC (default) and MNES (needs enabled by the user) options. <br />
<br />
====Automated Updates====<br />
Negotiating the '''NEW-ENVIRON''' telnet option provides game servers the capability to request one, multiple, or all client environment variables set within Mudlet. Game servers may send a telopt DO NEW-ENVIRON (39), Mudlet responds with a WILL NEW-ENVIRON (39), then the game server may send SB NEW-ENVIRON (39) SEND to receive all available environment variables. Mudlet will respond 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 sent to a server within the current connection, Mudlet will respond with SB NEW-ENVIRON (39) INFO (2) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] to which no reply from the server is needed. It is possible to send a specific list of requested environmental variables to Mudlet with the format SB NEW-ENVIRON (39) SEND < VAR (0) | USERVAR (3) > "<variable>" [ .. < VAR (0) | USERVAR (3) > "<variable>" ].<br />
<br />
Success example:<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC WILL CHARSET (42) <br />
| IAC DO CHARSET (42)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC WILL NEW-ENVIRON (39) <br />
| IAC DONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20667Area 512024-01-01T16:00:32Z<p>Tamarindo: /* Supported Protocols */</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols, PR #7058=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON, PR #7058==<br />
To enhance the player experience by sharing more client-supported details, the Telnet New-Environ Option may be used to transfer detail from Mudlet to game servers. Sharing supporting information on encoding, terminal emulation, and accessibility aims to ease initial player setup and increase the retention rate for new gaming community members.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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, and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: Mud New-Environ Standard, which shares a specific set of client information. <br />
<br />
====Manual Environment Updates====<br />
Mudlet supports manual selection of a number of options that may dynamically inform servers that have sent interest in knowing about these client environmental variables after negotiating the NEW-ENVIRON option. For example, when a Mudlet user update the server data encoding for a profile by choosing Settings, General and selecting a server data encoding from the corresponding drop-down menu, this information is available for transfer via both the RFC (default) and MNES (needs enabled by the user) options. <br />
<br />
====Automated Updates====<br />
Negotiating the '''NEW-ENVIRON''' telnet option provides game servers the capability to request one, multiple, or all client environment variables set within Mudlet. Game servers may send a telopt DO NEW-ENVIRON (39), Mudlet responds with a WILL NEW-ENVIRON (39), then the game server may send SB NEW-ENVIRON (39) SEND to receive all available environment variables. Mudlet will respond 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 sent to a server within the current connection, Mudlet will respond with SB NEW-ENVIRON (39) INFO (2) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] to which no reply from the server is needed. It is possible to send a specific list of requested environmental variables to Mudlet with the format SB NEW-ENVIRON (39) SEND < VAR (0) | USERVAR (3) > "<variable>" [ .. < VAR (0) | USERVAR (3) > "<variable>" ].<br />
<br />
Success example:<br />
{| class="wikitable"<br />
! Server<br />
! NEW-ENVIRON<br />
|-<br />
| IAC WILL CHARSET (42) <br />
| IAC DO CHARSET (42)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC WILL NEW-ENVIRON (39) <br />
| IAC DONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindohttps://wiki.mudlet.org/index.php?title=Area_51&diff=20666Area 512024-01-01T15:59:38Z<p>Tamarindo: NEW-ENVIRON</p>
<hr />
<div>{{TOC right}}<br />
<br />
This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in [[Manual:Lua_Functions|Lua Functions]] and its sub-sites. <br />
<br />
Please use the [[Area_51/Template]] to add new entries in the sections below.<br />
<br />
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.<br />
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki><br />
rather than:<br />
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki><br />
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!<br />
<br />
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.<br />
<br />
<br />
=Basic Essential Functions=<br />
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.<br />
<br />
=Database Functions=<br />
:A collection of functions for helping deal with the database.<br />
<br />
=Date/Time Functions=<br />
: A collection of functions for handling date & time.<br />
<br />
=File System Functions=<br />
: A collection of functions for interacting with the file system.<br />
<br />
=Mapper Functions=<br />
: A collection of functions that manipulate the mapper and its related features.<br />
<br />
==mapSymbolFontInfo, PR #4038 closed==<br />
;mapSymbolFontInfo()<br />
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;returns<br />
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:<br />
:* ''fontName'' - a string of the family name of the font specified<br />
:* ''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.<br />
:* ''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).<br />
* or ''nil'' and an error message on failure.<br />
<br />
::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).<br />
<br />
==moveMapLabel, PR #6014 open==<br />
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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).<br />
<br />
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014<br />
<br />
;Parameters<br />
* ''areaID/Name:''<br />
: Area ID as number or AreaName as string containing the map label.<br />
<br />
* ''labelID/Text:''<br />
: 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.<br />
<br />
* ''coordX/deltaX:''<br />
: 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.<br />
<br />
* ''coordY/deltaY:''<br />
: 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.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north<br />
moveMapLabel(0, 2, 3.0, 4.0)<br />
<br />
-- 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<br />
moveMapLabel(0, 2, -1.0, 0.0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, 2, -3.5, -2.0, true)<br />
<br />
-- move the second label in the area with the ID number of 2, up three levels<br />
moveRoom(1, 2, 0.0, 0.0, 3.0)<br />
<br />
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded<br />
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)<br />
<br />
-- 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:<br />
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are the indicated labels and areas<br />
</syntaxhighlight><br />
<br />
==moveRoom, PR #6010 open==<br />
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])<br />
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.<br />
<br />
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010<br />
<br />
;Parameters<br />
* ''roomID:''<br />
: Room ID number to move.<br />
<br />
* ''coordX/deltaX:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.<br />
<br />
* ''coordY/deltaY:''<br />
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.<br />
<br />
* ''coordZ/deltaZ:''<br />
: (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.<br />
<br />
* ''absoluteNotRelativeMove:''<br />
: (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'').<br />
<br />
;Returns<br />
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- move the first room one space to the east and two spaces to the north<br />
moveRoom(1, 1, 2)<br />
<br />
-- move the first room one space to the west, note the final boolean argument is unneeded<br />
moveRoom(1, -1, 0, false)<br />
<br />
-- 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**:<br />
moveRoom(1, -3, -2, true)<br />
<br />
-- move the second room up three levels<br />
moveRoom(2, 0, 0, 3)<br />
<br />
-- move the second room one space to the west, note the last two arguments are unneeded<br />
moveRoom(2, -1, 0, 0, false)<br />
<br />
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:<br />
moveRoom(2, 0, 0, 0, true)<br />
<br />
-- all of the above will return the 'true' boolean value assuming there are rooms with 1 and 2 as ID numbers<br />
</syntaxhighlight><br />
<br />
==setupMapSymbolFont, PR #4038 closed==<br />
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])<br />
:configures the font used for symbols in the (2D) map.<br />
: See also: [[#mapSymbolFontInfo|mapSymbolFontInfo()]]<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038<br />
<br />
;Parameters<br />
* ''fontName'' one of:<br />
:* - a string that is the family name of the font to use;<br />
:* - the empty string ''""'' to reset to the default {which is '''"Bitstream Vera Sans Mono"'''};<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow a following one to be modified.<br />
* ''onlyUseThisFont'' (optional) one of:<br />
:* - 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;<br />
:* - 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;<br />
:* - a Lua ''nil'' as a placeholder to not change this parameter but still allow the following one to be modified.<br />
* ''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.<br />
<br />
;Returns<br />
* ''true'' on success<br />
* ''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).<br />
<br />
=Miscellaneous Functions=<br />
: Miscellaneous functions.<br />
<br />
==playMusicFile, PR #7026==<br />
;playMusicFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| continue <br />
| true or false<br />
| true<br />
| style="text-align:left;" |<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile({<br />
name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile({<br />
name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 20000<br />
, fadeout = 53000<br />
, start = 10000<br />
, finish = 110000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "rugby"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,finish]) ----<br />
<br />
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a music file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playMusicFile(<br />
"C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play music stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music<br />
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [finish] 110 seconds from the track start (fadeout scales its volume decrease over a shorter duration, too)<br />
---- [key] reference of "rugby" for stopping this unique music later<br />
---- [tag] reference of "ambience" to stop and music later with the same tag<br />
---- [continue] playing this music if another request for the same music comes in (false restarts it) <br />
---- [url] to download once from the Internet if the music does not exist in the profile's media directory<br />
playMusicFile(<br />
"167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name<br />
, nil -- volume<br />
, 20000 -- fadein<br />
, 53000 -- fadeout<br />
, 10000 -- start<br />
, nil -- loops<br />
, "rugby" -- key <br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, 110000 -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==playSoundFile, PR #7026==<br />
;playSoundFile(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| name<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;"| No<br />
| volume<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
| fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| start<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;"| No<br />
| finish<br />
| <msec><br />
| <br />
| style="text-align:left;"|<br />
* Finish play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
| loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
* A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| url<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* Only required if the file is to be downloaded remotely.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{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].<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile({<br />
name = "cow.wav"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = getMudletHomeDir().. "/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile({<br />
name = "C:/Users/Tamarindo/Documents/cow.wav"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile({<br />
name = "cow.wav"<br />
, volume = 75<br />
, fadein = nil -- nil lines are optional, no need to use<br />
, fadeout = nil -- nil lines are optional, no need to use<br />
, start = nil -- nil lines are optional, no need to use<br />
, finish = nil -- nil lines are optional, no need to use<br />
, loops = 2<br />
, key = "cow"<br />
, tag = "animals"<br />
, priority = 25<br />
, url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url][,finish]) ----<br />
<br />
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playSoundFile(<br />
"cow.wav" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
getMudletHomeDir().. "/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playSoundFile(<br />
"C:/Users/Tamarindo/Documents/cow.wav" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a sound stored in the profile's media directory<br />
---- [volume] of 75<br />
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)<br />
---- [key] reference of "cow" for stopping this unique sound later<br />
---- [tag] reference of "animals" to stop a group of sounds later with the same tag<br />
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)<br />
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory<br />
playSoundFile(<br />
"cow.wav" -- name<br />
, 75 -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, 2 -- loops<br />
, "cow" -- key <br />
, "animals" -- tag<br />
, 25 -- priority<br />
, "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url<br />
, nil -- finish<br />
)<br />
</syntaxhighlight><br />
<br />
==stopMusic, PR #7026==<br />
;stopMusic(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
!Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
|<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
|<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
|<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playMusicFile().<br />
* If fadeout was not specified in playMusicFile(), then the optional fadeout parameter from stopMusic() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playMusicFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "rugby" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing music files for this profile associated with the API<br />
stopMusic({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopMusic({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all the unique "rugby" music for this profile associated with the API<br />
stopMusic({<br />
key = "rugby"<br />
, fadeaway = true<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing music files for this profile associated with the API<br />
stopMusic()<br />
<br />
-- Stop playing the rugby mp3 by name<br />
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")<br />
<br />
-- Stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
)<br />
<br />
-- Decrease the volume for 10 seconds then stop playing the unique sound identified as "rugby"<br />
stopMusic(<br />
nil -- name<br />
, "rugby" -- key<br />
, nil -- tag<br />
, true -- fadeaway<br />
, 10000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==stopSounds, PR #7026==<br />
;stopSounds(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|-<br />
| style="text-align:center;"| No<br />
| name<br />
| <file name><br />
| <br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
| key <br />
|<key><br />
| <br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;"| No<br />
| tag<br />
| <tag><br />
| <br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
| priority<br />
| 1 to 100<br />
| <br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a matching or lower priority.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeaway<br />
| true or false<br />
|false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in playSoundFile().<br />
* If fadeout was not specified in playSoundFile(), then the optional fadeout parameter from stopSounds() or a default of 5000 milliseconds will be applied.<br />
|-<br />
| style="text-align:center;"| No<br />
| fadeout<br />
| <br />
|5000<br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in playSoundFile().<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.15}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds({name = "cow.wav"})<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = nil -- nil lines are optional, no need to use<br />
, tag = "animals"<br />
, priority = 50<br />
})<br />
<br />
-- Decrease volume for 5 seconds and then stop all playing sound files for this profile associated with the API<br />
stopSounds({<br />
fadeaway = true<br />
})<br />
<br />
-- 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<br />
stopSounds({<br />
fadeaway = true<br />
, fadeout = 10000<br />
})<br />
<br />
-- Decrease volume for 3 seconds and then stop all the tagged "animals" music for this profile associated with the API<br />
stopSounds({<br />
tag = "animals"<br />
, fadeaway = true<br />
, fadeout = 3000<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority][,fadeaway][,fadeout]) ----<br />
<br />
-- Stop all playing sound files for this profile associated with the API<br />
stopSounds()<br />
<br />
-- Stop playing the cow sound<br />
stopSounds("cow.wav")<br />
<br />
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50<br />
---- This would not stop sounds tagged as "animals" greater than priority 50. This is an "AND" and not an "OR".<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, "animals" -- tag<br />
, 50 -- priority<br />
)<br />
<br />
-- Decrease the volume for 7 seconds and then stop playing sounds<br />
stopSounds(<br />
nil -- name<br />
, nil -- key<br />
, nil -- tag<br />
, nil -- priority<br />
, true -- fadeaway<br />
, 7000 -- fadeout<br />
)<br />
</syntaxhighlight><br />
<br />
==createVideoPlayer, PR #6439==<br />
;createVideoPlayer([name of userwindow], x, y, width, height)<br />
<br />
: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.<br />
<br />
{{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.<br />
<br />
{{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.<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create a 300x300 video player in the top-left corner of Mudlet<br />
createVideoPlayer(0,0,300,300)<br />
<br />
-- Alternative examples using Geyser.VideoPlayer<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})<br />
<br />
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({<br />
name = "GUI.VideoPlayer",<br />
x = "70%", y = 0, -- edit here if you want to move it<br />
width = "30%", height = "50%"<br />
}, GUI.Right)<br />
</syntaxhighlight><br />
<br />
==loadVideoFile, PR #6439==<br />
;loadVideoFile(settings table) or loadVideoFile(name, [url])<br />
: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.<br />
<br />
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")<br />
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if file to load is not part of the profile or on the local file system.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- OR download from the profile<br />
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- OR download from the local file system<br />
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----<br />
<br />
-- Download from the Internet<br />
loadVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
)<br />
<br />
-- OR download from the profile<br />
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- OR download from the local file system<br />
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")<br />
</syntaxhighlight><br />
<br />
==playVideoFile, PR #6439==<br />
;playVideoFile(settings table)<br />
: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>.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
!Default<br />
! style="text-align:left;" |Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;" |Yes<br />
|name<br />
|<file name><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Name of the media file.<br />
*May contain directory information (i.e. weather/maelstrom.mp4).<br />
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")<br />
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")<br />
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|-<br />
| style="text-align:center;" |No<br />
| volume<br />
|1 to 100<br />
|50<br />
| style="text-align:left;" |<br />
*Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadein<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|fadeout<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|start<br />
|<msec><br />
| 0<br />
| style="text-align:left;" |<br />
*Begin play at the specified position in milliseconds.<br />
|-<br />
| style="text-align:center;" |No<br />
|loops<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;" |<br />
*Number of iterations that the media plays.<br />
*A value of -1 allows the media to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
| style="text-align:center;" |No<br />
|continue<br />
|true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Continues playing matching new video files when true.<br />
*Restarts matching new video files when false.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|url<br />
|<url><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Resource location where the media file may be downloaded.<br />
*Only required if the file is to be downloaded remotely or for streaming from the Internet.<br />
|- style="color: blue;"<br />
| style="text-align:center;" |Maybe<br />
|stream<br />
|true or false<br />
|false<br />
| style="text-align:left;" |<br />
*Streams files from the Internet when true.<br />
*Download files when false (default).<br />
*Used in combination with the `url` key.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = true<br />
})<br />
<br />
-- 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.<br />
<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
})<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
})<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile({<br />
name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"<br />
, volume = 75<br />
})<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile({<br />
name = "TextInMotion-VideoSample-1080p.mp4"<br />
, volume = nil -- nil lines are optional, no need to use<br />
, fadein = 10000<br />
, fadeout = 15000<br />
, start = 5000<br />
, loops = nil -- nil lines are optional, no need to use<br />
, key = "text"<br />
, tag = "ambience"<br />
, continue = true<br />
, url = "https://d2qguwbxlx1sbt.cloudfront.net/"<br />
, stream = false<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----<br />
<br />
-- Stream a video file from the Internet and play it.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- 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.<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4"<br />
, nil -- volume<br />
, nil -- fadein<br />
, nil -- fadeout<br />
, nil -- start<br />
, nil -- loops<br />
, nil -- key<br />
, nil -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
<br />
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)<br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
)<br />
<br />
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR copy once from the local file system, and play a video file stored in the profile's media directory<br />
---- [volume] of 75 (1 to 100)<br />
playVideoFile(<br />
"C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name<br />
, 75 -- volume<br />
)<br />
<br />
-- OR download once from the Internet, and play a video stored in the profile's media directory<br />
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds<br />
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video<br />
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)<br />
---- [key] reference of "text" for stopping this unique video later<br />
---- [tag] reference of "ambience" to stop any video later with the same tag<br />
---- [continue] playing this video if another request for the same video comes in (false restarts it) <br />
---- [url] resource location where the file may be accessed on the Internet<br />
---- [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) <br />
playVideoFile(<br />
"TextInMotion-VideoSample-1080p.mp4" -- name<br />
, nil -- volume<br />
, 10000 -- fadein<br />
, 15000 -- fadeout<br />
, 5000 -- start<br />
, nil -- loops<br />
, "text" -- key<br />
, "ambience" -- tag<br />
, true -- continue<br />
, "https://d2qguwbxlx1sbt.cloudfront.net/" -- url<br />
, false -- stream<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==stopVideos, PR #6439==<br />
;stopVideos(settings table)<br />
: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()]].<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" |No<br />
| name<br />
| <file name><br />
| style="text-align:left;" |<br />
* Name of the media file.<br />
|-<br />
| style="text-align:center;" |No<br />
|key<br />
|<key><br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|tag<br />
|<tag><br />
| style="text-align:left;" |<br />
*Helps categorize media.<br />
|-<br />
|}<br />
<br />
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]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Example<br />
<br />
<syntaxhighlight lang="lua"><br />
---- Table Parameter Syntax ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos({<br />
name = nil -- nil lines are optional, no need to use<br />
, key = "text" -- key<br />
, tag = nil -- nil lines are optional, no need to use<br />
})<br />
</syntaxhighlight><br />
<syntaxhighlight lang="lua"><br />
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----<br />
<br />
-- Stop all playing video files for this profile associated with the API<br />
stopVideos()<br />
<br />
-- Stop playing the text mp4 by name<br />
stopVideos("TextInMotion-VideoSample-1080p.mp4")<br />
<br />
-- Stop playing the unique sound identified as "text"<br />
stopVideos(<br />
nil -- name<br />
, "text" -- key<br />
, nil -- tag<br />
)<br />
</syntaxhighlight><br />
<br />
<br />
==getCustomLoginTextId, PR #3952 open==<br />
;getCustomLoginTextId()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCharacterName, PR #3952 open==<br />
;sendCharacterName()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
==sendCharacterPassword, PR #3952 open==<br />
;sendCharacterPassword()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCharacterName() ~= "" then<br />
tempTime(2.0, [[sendCharacterName()]], 1)<br />
tempTime(3.0, [[sendCharacterPassword()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
==sendCustomLoginText, PR #3952 open ==<br />
;sendCustomLoginText()<br />
<br />
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.<br />
<br />
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.<br />
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].<br />
<br />
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952<br />
<br />
Only one custom login text has been defined initially:<br />
{| class="wikitable"<br />
|+Predefined custom login texts<br />
|-<br />
!Id!!Custom text!!Introduced in Mudlet version<br />
|-<br />
|1||"connect {character name} {password}"||TBD<br />
|}<br />
<br />
The addition of further texts would be subject to negotiation with the Mudlet Makers.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:<br />
function doLogin()<br />
if getCustomLoginTextId() ~= 1 then<br />
-- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is<br />
echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")<br />
else<br />
tempTime(2.0, [[sendCustomLoginText()]], 1)<br />
end<br />
end<br />
</syntaxhighlight><br />
<br />
=Mudlet Object Functions=<br />
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.<br />
<br />
==ancestors, new in PR #6726==<br />
;ancestors(IDnumber, type)<br />
:You can use this function to find out about all the ancestors of something.<br />
<br />
: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:<br />
:* its IDnumber as a number<br />
:* its name as a string<br />
:* whether it is active as a boolean<br />
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)<br />
:Returns ''nil'' and an error message if either parameter is not valid<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: 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).<br />
* ''type:''<br />
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.<br />
<br />
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
==findItems, new in PR #6742==<br />
;findItems("name", "type"[, exact[, case sensitive]])<br />
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.<br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.<br />
* ''exact:''<br />
:(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.<br />
* ''case sensitive:''<br />
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.<br />
<br />
;Example<br />
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:<br />
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]<br />
<br />
<syntaxhighlight lang="lua"><br />
-- Should find just the package with the name:<br />
lua findItems("echo", "alias")<br />
{ 3 }<br />
<br />
-- Should find both the package and the alias - as the latter contains "echo" with another character<br />
lua findItems("echo", "alias", false)<br />
{ 3, 4 }<br />
<br />
-- Finds the ID numbers of all the aliases:<br />
lua findItems("", "alias", false)<br />
{ 1, 2, 3, 4, 5, 6, 7 }<br />
<br />
-- Will still find the package with the name "echo" as we are not concerned with the casing now:<br />
lua findItems("Echo", "alias", true, false)<br />
{ 3 }<br />
<br />
-- Won't find the package with the name "echo" now as we are concerned with the casing:<br />
lua findItems("Echo", "alias", true, true)<br />
{}<br />
</syntaxhighlight><br />
<br />
==isActive, modified by PR #6726==<br />
;isActive(name/IDnumber, type[, checkAncestors])<br />
:You can use this function to check if something, or somethings, are active. <br />
<br />
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.<br />
<br />
;Parameters<br />
* ''name:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').<br />
* ''checkAncestors:''<br />
:(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''').<br />
<br />
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")<br />
<br />
-- Can also be used to check if a specific item is enabled or not.<br />
if isActive("spellname", "trigger") > 0 then<br />
-- the spellname trigger is active<br />
else<br />
-- it is not active<br />
end<br />
</syntaxhighlight><br />
<br />
{{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.<br />
<br />
==isAncestorsActive, new in PR #6726==<br />
;isAncestorsActive(IDnumber, "type")<br />
: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(...)]]). <br />
<br />
: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.<br />
<br />
;Parameters<br />
* ''IDnumber:''<br />
: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).<br />
* ''type:''<br />
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.<br />
<br />
:See also: [[#exists|exists(...)]]<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- To do<br />
</syntaxhighlight><br />
<br />
=Networking Functions=<br />
:A collection of functions for managing networking.<br />
<br />
=String Functions=<br />
:These functions are used to manipulate strings.<br />
<br />
=Table Functions=<br />
: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.<br />
<br />
=Text to Speech Functions=<br />
: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.<br />
<br />
=UI Functions=<br />
: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.<br />
<br />
==cecho2decho PR#6849 merged==<br />
; convertedString = cecho2decho(str)<br />
<br />
:Converts a cecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
decho(cecho2decho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2hecho PR#6849 merged==<br />
; convertedString = cecho2hecho(str)<br />
<br />
:Converts a cecho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
hecho(cecho2hecho(cechoString))<br />
</syntaxhighlight><br />
<br />
==cecho2html PR#6849 merged==<br />
; convertedString = cecho2html(str[, resetFormat])<br />
<br />
:Converts a cecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from cecho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the cecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = cecho2html(cechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==decho2cecho PR#6849 merged==<br />
; convertedString = decho2cecho(str)<br />
<br />
:Converts a decho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use cecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
cecho(decho2cecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2hecho PR#6849 merged==<br />
; convertedString = decho2hecho(str)<br />
<br />
:Converts a decho formatted string to an hecho formatted one. <br />
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
;Returns <br />
* a string formatted for hecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to an hecho string and use hecho to display it<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
hecho(decho2hecho(dechoString))<br />
</syntaxhighlight><br />
<br />
==decho2html PR#6849 merged==<br />
; convertedString = decho2html(str[, resetFormat])<br />
<br />
:Converts a decho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from decho to decho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the decho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = decho2html(dechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==deleteMultiline PR-6779 merged==<br />
<br />
; ok,err = deleteMultiline([triggerDelta])<br />
<br />
: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.<br />
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
{{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.<br />
<br />
;Parameters<br />
* ''[optional]triggerDelta:''<br />
: 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.<br />
<br />
;Returns <br />
* true if the function was able to run successfully, nil+error if something went wrong.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- if this trigger has a line delta of 3, you would call<br />
deleteMultiline(3)<br />
<br />
-- same thing, but with error handling<br />
local ok,err = deleteMultiline(3)<br />
if not ok then<br />
cecho("\n<firebrick>I could not delete the lines because: " .. err)<br />
end<br />
</syntaxhighlight><br />
<br />
; Additional development notes<br />
<br />
==echoPopup, revised in PR #6945==<br />
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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).<br />
::* 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.<br />
::* 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. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!<br />
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)<br />
echo(" remaining text.\n")<br />
<br />
</syntaxhighlight><br />
<br />
==hecho2cecho PR#6849 merged==<br />
; convertedString = hecho2cecho(str)<br />
<br />
:Converts a hecho formatted string to a cecho formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to cecho<br />
;Returns <br />
* a string formatted for cecho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a hecho string and use cecho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
cecho(hecho2cecho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2decho PR#6849 merged==<br />
; convertedString = hecho2decho(str)<br />
<br />
:Converts a hecho formatted string to a decho formatted one. <br />
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to decho<br />
;Returns <br />
* a string formatted for decho<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- convert to a decho string and use decho to display it<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
decho(hecho2decho(hechoString))<br />
</syntaxhighlight><br />
<br />
==hecho2html PR#6849 merged==<br />
; convertedString = hecho2html(str[, resetFormat])<br />
<br />
:Converts a hecho formatted string to an html formatted one. <br />
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]<br />
<br />
{{MudletVersion|4.18}}<br />
<br />
;Parameters<br />
* ''str''<br />
: string you wish to convert from hecho to hecho<br />
* ''resetFormat''<br />
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]<br />
;Returns <br />
* a string formatted for html<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- create the base string<br />
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""<br />
<br />
-- create a label to display the result onto<br />
testLabel = Geyser.Label:new({name = "testLabel"})<br />
<br />
-- convert the hecho string to an html one, using the default formatting of testLabel created above<br />
local htmlString = hecho2html(hechoString, testLabel:getFormat())<br />
<br />
-- and finally echo it to the label to see<br />
-- I use rawEcho as that displays the html exactly as given.<br />
testLabel:rawEcho(htmlString)<br />
</syntaxhighlight><br />
<br />
==insertPopup, revised in PR #6925==<br />
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])<br />
: 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.<br />
<br />
; Parameters<br />
* ''windowName:''<br />
: (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.<br />
* ''text:''<br />
: the text string to display.<br />
* ''{commands}:''<br />
: 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>.<br />
* ''{hints}:''<br />
: 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.<br />
* ''{tool-tips}:''<br />
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided. <br />
* ''useCurrentFormatElseDefault:''<br />
: (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.<br />
<br />
{{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.<br />
<br />
;Example<br />
<syntaxhighlight lang="lua"><br />
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':<br />
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})<br />
<br />
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)<br />
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})<br />
<br />
-- one can also provide helpful information<br />
<br />
-- todo: an example with rich-text in the tool-tips(s)<br />
<br />
</syntaxhighlight><br />
<br />
=Discord Functions=<br />
: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]].<br />
<br />
=Mud Client Media Protocol=<br />
: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]].<br />
<br />
==Playing Media, PR #7026==<br />
<br />
===Playing Media===<br />
<br />
Send '''Client.Media.Play''' GMCP events to play sound or music files.<br />
<br />
{| class="wikitable"<br />
! Required<br />
! Key<br />
! Value<br />
! Default<br />
! style="text-align:left;"| Purpose<br />
|- style="color: green;"<br />
| style="text-align:center;"| Yes<br />
| "name"<br />
| <file name><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Name of the media file.<br />
* May contain directory information (i.e. weather/lightning.wav).<br />
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.<br />
|- style="color: blue;"<br />
| style="text-align:center;"| Maybe<br />
| "url"<br />
| <url><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Resource location where the media file may be downloaded.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "type"<br />
| "sound" or "music"<br />
| "sound"<br />
| style="text-align:left;"|<br />
* Identifies the type of media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "tag"<br />
| <tag><br />
| &nbsp;<br />
| style="text-align:left;"|<br />
* Helps categorize media.<br />
|-<br />
| style="text-align:center;"| No<br />
| "volume"<br />
| 1 to 100<br />
| 50<br />
| style="text-align:left;"|<br />
* Relative to the volume set on the player's client.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadein"<br />
|<msec><br />
|<br />
|<br />
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.<br />
*Start position: Start of media.<br />
*End position: Start of media plus the number of milliseconds (msec) specified.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"fadeout"<br />
|<msec><br />
|<br />
|<br />
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.<br />
*Start position: End of the media minus the number of milliseconds (msec) specified.<br />
*End position: End of the media.<br />
*1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "start"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* Begin play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;"| No<br />
| "finish"<br />
| <msec><br />
| 0<br />
| style="text-align:left;"|<br />
* End play at the specified position in milliseconds.<br />
* 1000 milliseconds = 1 second.<br />
|-<br />
| style="text-align:center;" |No<br />
|"loops"<br />
| -1, or >= 1<br />
|1<br />
| style="text-align:left;"|<br />
* Number of iterations that the media plays.<br />
* A value of -1 allows the sound or music to loop indefinitely.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Halts the play of current or future played media files with a lower priority while this media plays.<br />
|-<br />
| style="text-align:center;" |No<br />
|"continue"<br />
| true or false<br />
|true<br />
| style="text-align:left;" |<br />
*Only valid for media files with a "type" of "music".<br />
*Continues playing matching new music files when true.<br />
*Restarts matching new music files when false.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
|&nbsp;<br />
| style="text-align:left;" |<br />
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".<br />
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.<br />
|-<br />
|}<br />
<br />
==== name====<br />
<br />
For example, to simply play the sound of a cow mooing already stored in the "media" folder:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Or some lightning stored in a "weather" sub-folder under the "media" folder.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "weather/lightning.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
The "name" parameter may be used for stopping media with the Client.Media.Stop GMCP event.<br />
<br />
====url====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"url": "https://www.example.com/sounds/"<br />
}<br />
</syntaxhighlight><br />
<br />
====type: sound====<br />
<br />
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:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "cow.wav",<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====tag====<br />
<br />
To play the sound of a sword swooshing and categorized as "combat":<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat"<br />
}<br />
</syntaxhighlight><br />
<br />
The "tag" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====type: music====<br />
<br />
Add background music to your environment through use of the "music" value set upon the "type" parameter:<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment"<br />
}<br />
</syntaxhighlight><br />
<br />
The "type" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====volume: 1 to 100====<br />
<br />
As the character draws nearer to or farther from the environmental feature, consider adjusting the "volume" parameter. Example values, followed by syntax examples:<br />
<br />
*Maximum: 100 (recommended to use rarely)<br />
*High: 75<br />
*Default: 50<br />
* Low: 25<br />
* Minimum: 1 (recommended to use rarely)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "river.wav",<br />
"type": "music",<br />
"tag": "environment",<br />
"volume": 75<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "volume" values of type string ("75") into integers (75) as needed.<br />
<br />
====fadein====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade in)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "monty_python.mp3",<br />
"type": "music",<br />
"volume": 100,<br />
"fadein": 1000<br />
}<br />
</syntaxhighlight><br />
+---------------------------+-----------------------+<br />
| Fade in 1000 milliseconds | Normal |<br />
+---------------------------+-----------------------+<br />
Volume 1|........::::::::::iiiiiiiii%%%%%%%%%%%%%%%%%%%%%%%%|Volume 100<br />
+---------------------------+-----------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadein" values of type string ("1000") into integers (1000) as needed.<br />
<br />
==== fadeout====<br />
<br />
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:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (no fade out)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "the_matrix.mp3",<br />
"type": "music",<br />
"volume": 50,<br />
"fadeout": 333<br />
}<br />
</syntaxhighlight><br />
+-----------------------+---------------------------+<br />
| Normal | Fade out 333 milliseconds |<br />
+-----------------------+---------------------------+<br />
Volume 50|%%%%%%%%%%%%%%%%%%%%%%%%iiiiiiiii::::::::::........|Volume 1<br />
+-----------------------+---------------------------+<br />
Although using the integer type is recommended, Mudlet parses "fadeout" values of type string ("333") into integers (333) as needed.<br />
<br />
==== start ====<br />
<br />
Start playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"start": 1000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "start" values of type string ("100") into integers (100) as needed.<br />
<br />
==== finish ====<br />
<br />
Finish playing a media track at the number of milliseconds specified. Example values, followed by syntax examples:<br />
<br />
*1000 milliseconds (1 second)<br />
*60000 milliseconds (1 minute)<br />
*0 milliseconds (start from beginning)<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "mudlet_beatboxing.mp3",<br />
"type": "music",<br />
"volume": 75,<br />
"finish": 35000<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "finish" values of type string ("100") into integers (100) as needed.<br />
<br />
==== loops: -1, 1 or more ====<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "clock/hour_bell.wav",<br />
"type": "sound",<br />
"loops": 3<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "underdark.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "loops" values of type string ("-1") into integers (-1) as needed.<br />
<br />
==== priority: 1 to 100 ====<br />
<br />
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.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sword1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3,<br />
"priority": 60<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "block1.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"priority": 70<br />
}<br />
</syntaxhighlight><br />
<br />
Although using the integer type is recommended, Mudlet parses "priority" values of type string ("25") into integers (25) as needed.<br />
<br />
The "priority" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
====continue: true or false (for music)====<br />
<br />
Typically sent with the "type" of "music" is the parameter "continue", which presents the following values:<br />
<br />
*true: continues music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
*false: restarts music that is already playing if it is requested again through a new Client.Media.Play GMCP event<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "city.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"continue": true<br />
}<br />
</syntaxhighlight><br />
<br />
If the "continue" parameter is not specified, behavior will default to ''true'' for music.<br />
<br />
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.<br />
<br />
==== key====<br />
<br />
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.<br />
<br />
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. <br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "sewer.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
<br />
Client.Media.Play {<br />
"name": "village.mp3",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": true,<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
The "key" parameter may be used for stopping matching media with the Client.Media.Stop GMCP event.<br />
<br />
{{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.<br />
<br />
==== randomization====<br />
<br />
Wildcards ''*'' (asterisk) and ''?'' (question mark) may be used within the name to randomize media file(s) selection.<br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "underdark*",<br />
"type": "music",<br />
"tag": "environment",<br />
"loops": -1,<br />
"continue": false<br />
}<br />
</syntaxhighlight><br />
<br />
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.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Play {<br />
"name": "combat/sword?.wav",<br />
"type": "sound",<br />
"tag": "combat",<br />
"loops": 3<br />
}<br />
</syntaxhighlight><br />
<br />
==Stopping Media, PR #7026==<br />
<br />
=== Stopping Media ===<br />
<br />
Send '''Client.Media.Stop''' GMCP events to stop sound or music media.<br />
<br />
{| class="wikitable"<br />
!Required<br />
!Key<br />
!Value<br />
! style="text-align:left;" |Purpose<br />
|-<br />
| style="text-align:center;" | No<br />
| "name"<br />
|<file name><br />
| style="text-align:left;" |<br />
*Stops playing media by name matching the value specified.<br />
|-<br />
| style="text-align:center;" | No<br />
|"type"<br />
|"sound" or "music"<br />
| style="text-align:left;" | <br />
*Stops playing media by type matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
| "tag"<br />
|<tag><br />
| style="text-align:left;" |<br />
*Stops playing media by tag matching the value specified.<br />
|-<br />
| style="text-align:center;" |No<br />
|"priority"<br />
|1 to 100<br />
| style="text-align:left;" |<br />
*Stops playing media with priority less than or equal to the value.<br />
|-<br />
| style="text-align:center;" |No<br />
|"key"<br />
|<key><br />
| style="text-align:left;" | <br />
*Stops playing media by key matching the value specified.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeaway"<br />
| true or false<br />
| style="text-align:left;" |<br />
* Decrease volume from the current position for a given duration, then stops the track.<br />
* Given duration is the lesser of the remaining track duration or the fadeout specified in Client.Media.Play.<br />
* 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.<br />
|-<br />
| style="text-align:center;"| No<br />
| "fadeout"<br />
| <br />
| style="text-align:left;" |<br />
* Default duration in milliseconds to decrease volume to the end of the track.<br />
* Only used if fadeout was not defined in Client.Media.Play.<br />
|-<br />
|}<br />
<br />
====all====<br />
<br />
Send the Client.Media.Stop GMCP event with no parameters to stop all playing media within a given game profile.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {}<br />
</syntaxhighlight><br />
<br />
====parameters====<br />
<br />
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.<br />
<br />
Stop the rain.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"name": "rain.wav"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media using the "type" of "sound".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"type": "sound"<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "tag" of "combat" ''and'' that has a "priority" less than or equal to 50.<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"tag": "combat",<br />
"priority": 50<br />
}<br />
</syntaxhighlight><br />
<br />
Stop all media categorized with the "key" of "area-music".<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music"<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 5 seconds (or the fadeout parameter defined in Client.Media.Play) and then stop all playing music files for this profile<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"fadeaway": true<br />
}<br />
</syntaxhighlight><br />
<br />
Decrease volume for 10 seconds all media categorized with the "key" of "area-music" and then stop the music<br />
<br />
<syntaxhighlight lang="json"><br />
Client.Media.Stop {<br />
"key": "area-music",<br />
"fadeaway": true,<br />
"fadeout": 10000<br />
}<br />
</syntaxhighlight><br />
<br />
=Supported Protocols=<br />
<br />
Mudlet supports CHARSET, NEW-ENVIRON, MTTS, MNES, GMCP, MSSP, MSP, ATCP, Aardwolfs 102, MSDP, and the MXP Protocol.<br />
<br />
CHARSET, NEW-ENVIRON, MTTS, MXP, MSSP, MSP, GMCP and 102 are enabled by default, MSDP and MNES can be enabled in settings.<br />
<br />
==NEW-ENVIRON==<br />
To enhance the player experience by sharing more client-supported details, the Telnet New-Environ Option may be used to transfer detail from Mudlet to game servers. Sharing supporting information on encoding, terminal emulation, and accessibility aims to ease initial player setup and increase the retention rate for new gaming community members.<br />
<br />
===NEW-ENVIRON in Mudlet===<br />
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, and the second is [https://tintin.mudhalla.net/protocols/mnes/ MNES]: Mud New-Environ Standard, which shares a specific set of client information. <br />
<br />
====Manual Environment Updates====<br />
Mudlet supports manual selection of a number of options that may dynamically inform servers that have sent interest in knowing about these client environmental variables after negotiating the NEW-ENVIRON option. For example, when a Mudlet user update the server data encoding for a profile by choosing Settings, General and selecting a server data encoding from the corresponding drop-down menu, this information is available for transfer via both the RFC (default) and MNES (needs enabled by the user) options. <br />
<br />
====Automated Updates====<br />
Negotiating the '''NEW-ENVIRON''' telnet option provides game servers the capability to request one, multiple, or all client environment variables set within Mudlet. Game servers may send a telopt DO NEW-ENVIRON (39), Mudlet responds with a WILL NEW-ENVIRON (39), then the game server may send SB NEW-ENVIRON (39) SEND to receive all available environment variables. Mudlet will respond 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 sent to a server within the current connection, Mudlet will respond with SB NEW-ENVIRON (39) INFO (2) < VAR (0) | USERVAR (3) > "<variable>" [VAL (1)] ["<value>"] to which no reply from the server is needed. It is possible to send a specific list of requested environmental variables to Mudlet with the format SB NEW-ENVIRON (39) SEND < VAR (0) | USERVAR (3) > "<variable>" [ .. < VAR (0) | USERVAR (3) > "<variable>" ].<br />
<br />
Success example:<br />
{| class="wikitable"<br />
! Server<br />
! NEW-ENVIRON<br />
|-<br />
| IAC WILL CHARSET (42) <br />
| IAC DO CHARSET (42)<br />
|-<br />
| IAC SB NEW-ENVIRON (39) SEND USERVAR (3) ''CHARSET'' IAC SE<br />
| IAC SB NEW-ENVIRON (39) IS USERVAR (3) ''CHARSET'' VAL (1) ''UTF-8'' IAC SE<br />
|-<br />
|}<br />
<br />
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.<br />
{| class="wikitable"<br />
! Server<br />
! Mudlet<br />
|-<br />
| IAC WILL NEW-ENVIRON (39) <br />
| IAC DONT NEW-ENVIRON (39)<br />
|-<br />
|}<br />
<br />
NEW-ENVIRON negotiation is available in Mudlet 4.18+.<br />
<br />
=Events=<br />
: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.<br />
<br />
===sysMapAreaChanged, PR #6615===<br />
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.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615<br />
<br />
<br />
===sysWindowOverflowEvent, PR #6872===<br />
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.<br />
<br />
{{MudletVersion| ?.??}}<br />
<br />
{{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).</div>Tamarindo