Difference between revisions of "Area 51"

From Mudlet
Jump to navigation Jump to search
 
(209 intermediate revisions by 11 users not shown)
Line 4: Line 4:
  
 
Please use the [[Area_51/Template]] to add new entries in the sections below.
 
Please use the [[Area_51/Template]] to add new entries in the sections below.
 +
 +
Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the <nowiki>'#'</nowiki> character in the link identifier on the left side of the <nowiki>'|'</nowiki> divider between the identifier and the display text. e.g.
 +
:: <nowiki>[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]</nowiki>
 +
rather than:
 +
:: <nowiki>[[#getCustomLines|getCustomLines()]]</nowiki>
 +
which would refer to a link within the ''current'' (in this case '''Area 51''') section. Note that this ought to be removed once the article is moved to the main wiki area!
  
 
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.
 
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.
Line 22: Line 28:
 
=Mapper Functions=
 
=Mapper Functions=
 
: A collection of functions that manipulate the mapper and its related features.
 
: A collection of functions that manipulate the mapper and its related features.
 +
 +
==addRoom PR #7184 merged==
 +
;addRoom(roomID, areaID)
 +
 +
:Creates a new room with the given room ID and area ID, returns true if the room was successfully created.
 +
 +
;Parameters
 +
* ''roomID:''
 +
: Room ID to set the room as, manually assigned or from [[#createRoomID|createRoomID()]].
 +
* ''areaID:''
 +
: Area ID to set the room in, as returned by [[#getAreaTable|getAreaTable()]] or equivalents.
 +
 +
{{note}} If you're not using incremental room IDs but room IDs stitched together from other factors or in-game hashes for room IDs - and your room IDs are starting off at 250+million numbers, you need to look into incrementally creating Mudlets room IDs with [[#createRoomID|createRoomID()]] and associating your room IDs with Mudlets via [[#setRoomIDbyHash|setRoomIDbyHash()]] and [[#getRoomIDbyHash|getRoomIDbyHash()]]. The reason being is that Mudlet's A* pathfinding implementation from boost cannot deal with extremely large room IDs because the resulting matrices it creates for pathfinding are enormously huge.
 +
{{note}} Creating your own mapping script? Check out more [[Manual:Mapper#Making_your_own_mapping_script|information here]].
 +
 +
: See also: [[#createRoomID|createRoomID()]]
 +
 +
;Example:
 +
<syntaxhighlight lang="lua">
 +
local newroomid = createRoomID()
 +
addRoom(newroomid)
 +
</syntaxhighlight>
 +
 +
==getAreaRooms1, PR #7520 open==
 +
;getAreaRooms1(area id)
 +
 +
:Returns an indexed table with all rooms IDs for a given area ID (room IDs are values), or ''nil'' if no such area exists. Indexing starts at 1.
 +
 +
See also: [[#getAreaRooms|getAreaRooms()]]
 +
 +
==setRoomArea PR #7184 merged====
 +
;setRoomArea(roomID, newAreaID or newAreaName)
 +
 +
:Assigns the given room (or set of rooms) to a new or different area. If the area is displayed in the mapper this will have the room be visually moved into the area as well.
 +
:roomID can also be a table of rooms for bulk assigning
 +
 +
: See also: [[#resetRoomArea|resetRoomArea()]]
 +
 +
;Example:
 +
<syntaxhighlight lang="lua">
 +
local newroomid = createRoomID()
 +
setRoomArea(newroomid, "My New Area")
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="lua">
 +
local rooms = { 1234, 4321, 5678 }
 +
setRoomArea(rooms, "My New Area")
 +
</syntaxhighlight>
 +
 +
==updateMap==
 +
;updateMap()
 +
 +
:Updates the mapper display (redraws it). While longer necessary since Mudlet 4.18, you can use this this function to redraw the map after changing it via API.
 +
 +
: See also: [[#centerview|centerview()]]
 +
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- delete a some room
 +
deleteRoom(500)
 +
-- now make the map show that it's gone
 +
updateMap()
 +
</syntaxhighlight>
 +
  
 
==mapSymbolFontInfo, PR #4038 closed==
 
==mapSymbolFontInfo, PR #4038 closed==
Line 38: Line 108:
 
::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).
 
::As the symbol font details are stored in the (binary) map file rather than the profile then this function will not work until a map is loaded (or initialized, by activating a map window).
  
 +
==moveMapLabel, PR #6014 open==
 +
;moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
 +
Re-positions a map label within an area in the 2D mapper, in a similar manner as the [[#moveRoom|moveRoom()]] function does for rooms and their custom exit lines. When moving a label to given coordinates this is the position that the top-left corner of the label will be positioned at; since the space allocated to a particular room on the map is ± 0.5 around the integer value of its x and y coordinates this means for a label which has a size of 1.0 x 1,0 (w x h) to position it centrally in the space for a single room at the coordinates (x, y, z) it should be positioned at (x - 0.5, y + 0.5, z).
 +
 +
:See also: [[Manual:Mapper_Functions#getMapLabels|getMapLabels()]], [[Manual:Mapper_Functions#getMapLabel|getMapLabel()]].
 +
 +
{{MudletVersion| ?.??}}
 +
 +
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6014
 +
 +
;Parameters
 +
* ''areaID/Name:''
 +
: Area ID as number or AreaName as string containing the map label.
 +
 +
* ''labelID/Text:''
 +
: Label ID as number (which will be 0 or greater) or the LabelText on a text label. All labels will have a unique ID number but there may be more than one ''text'' labels with a non-empty text string; only the first matching one will be moved by this function and image labels also have no text and will match the empty string.  with mo or AreaName as string containing the map label.
 +
 +
* ''coordX/deltaX:''
 +
: A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the X-axis.
 +
 +
* ''coordY/deltaY:''
 +
: A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Y-axis.
 +
 +
* ''coordZ/deltaZ:''
 +
: (Optional) A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Z-axis, if omitted the label is not moved in the z-axis at all.
 +
 +
* ''absoluteNotRelativeMove:''
 +
: (Optional) a boolean value (defaults to ''false'' if omitted) as to whether to move the label to the absolute coordinates (''true'') or to move it the relative amount from its current location (''false'').
 +
 +
;Returns
 +
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.
 +
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
 +
moveMapLabel(0, 2, 3.0, 4.0)
 +
 +
-- move the first label in the area with the ID number of 2, one space to the west, note the final boolean argument is unneeded
 +
moveMapLabel(0, 2, -1.0, 0.0, false)
 +
 +
-- move the second label in the area with the ID number of 2, three and a half spaces to the west, and two south **of the center of the current level it is on in the map**:
 +
moveRoom(1, 2, -3.5, -2.0, true)
 +
 +
-- move the second label in the area with the ID number of 2, up three levels
 +
moveRoom(1, 2, 0.0, 0.0, 3.0)
 +
 +
-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded
 +
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)
 +
 +
-- move the (top-left corner of the first) label with the text "Home" in the area with ID number 5 to the **center of the whole map**, note the last two arguments are required in this case:
 +
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)
 +
 +
-- all of the above will return the 'true'  boolean value assuming there are the indicated labels and areas
 +
</syntaxhighlight>
 +
 +
==moveRoom, PR #6010 open==
 +
;moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])
 +
Re-positions a room within an area, in the same manner as the "move to" context menu item for one or more rooms in the 2D mapper. Like that method this will also shift the entirety of any custom exit lines defined for the room concerned. This contrasts with the behavior of the [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]] which only moves the starting point of such custom exit lines so that they still emerge from the room to which they belong but otherwise remain pointing to the original place.
 +
 +
:See also: [[Manual:Mapper_Functions#setRoomCoordinates|setRoomCoordinates()]]
 +
 +
{{MudletVersion| ?.??}}
 +
 +
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6010
 +
 +
;Parameters
 +
* ''roomID:''
 +
: Room ID number to move.
 +
 +
* ''coordX/deltaX:''
 +
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.
 +
 +
* ''coordY/deltaY:''
 +
: The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.
 +
 +
* ''coordZ/deltaZ:''
 +
: (Optional) the absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Z-axis, if omitted the room is not moved in the z-axis at all.
 +
 +
* ''absoluteNotRelativeMove:''
 +
: (Optional) a boolean value (defaults to ''false'' if omitted) as to whether to move the room to the absolute coordinates (''true'') or the relative amount from its current location (''false'').
 +
 +
;Returns
 +
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.
 +
 +
;Example
 +
<syntaxhighlight lang="lua">
 +
-- move the first room one space to the east and two spaces to the north
 +
moveRoom(1, 1, 2)
 +
 +
-- move the first room one space to the west, note the final boolean argument is unneeded
 +
moveRoom(1, -1, 0, false)
 +
 +
-- move the first room three spaces to the west, and two south **of the center of the current level it is on in the map**:
 +
moveRoom(1, -3, -2, true)
 +
 +
-- move the second room up three levels
 +
moveRoom(2, 0, 0, 3)
 +
 +
-- move the second room one space to the west, note the last two arguments are unneeded
 +
moveRoom(2, -1, 0, 0, false)
 +
 +
-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:
 +
moveRoom(2, 0, 0, 0, true)
 +
 +
-- all of the above will return the 'true'  boolean value assuming there are rooms with 1 and 2 as ID numbers
 +
</syntaxhighlight>
  
 
==setupMapSymbolFont, PR #4038 closed==
 
==setupMapSymbolFont, PR #4038 closed==
Line 64: Line 240:
 
: Miscellaneous functions.
 
: Miscellaneous functions.
  
==getCharacterName, PR #3952 open==
+
==compare, PR#7122 open==
;getCharacterName()
 
  
:Returns the name entered into the "Character name" field on the Connection Preferences form. Can be used to find out the name that might need to be handled specially in scripts or anything that needs to be personalized to the player. If there is nothing set in that entry will return an empty string.
+
; sameValue = compare(a, b)
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined ''doLogin()'' function that may be replaced for more sophisticated requirements.
 
  
:See also: [[#sendCharacterName|sendCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
+
: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''
  
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
+
;See also: [[Manual:Lua_Functions#table.complement|table.complement()]], [[Manual:Lua_Functions#table.n_union|table.n_union()]]
  
;Example
+
{{MudletVersion|4.18}}
<syntaxhighlight lang="lua">
 
lua send("cast 'glamor' " .. getCharacterName())
 
  
You get a warm feeling passing from your core to the tips of your hands, feet and other body parts.
+
;Parameters
A small twittering bird settles on your shoulder and starts to look adoringly at you.
+
* ''a:''
A light brown faun gambles around you and then nuzzles your hand.
+
: The first item to compare
A tawny long-haired cat saunters over and start to rub itself against your ankles.
+
* ''b:''
A small twittering bird settles on your shoulder and starts to look adoringly at you.
+
: The second item to compare
A light brown faun gambles around you and then nuzzles your hand.
 
A small twittering bird settles on your shoulder and starts to look adoringly at you.
 
A mangy dog trots up to you and proceeds to mark the bottom of your leggings.
 
</syntaxhighlight>
 
  
==getCustomLoginTextId, PR #3952 open==
+
;Returns
;getCustomLoginTextId()
+
* Boolean true if the items have the same value, otherwise boolean false
 
 
Returns the Id number of the custom login text setting from the profile's preferences. Returns ''0'' if the option is disabled or a number greater than that for the item in the table; note it is possible if using an old saved profile in the future that the number might be higher than expected. As a design policy decision it is not permitted for a script to change the setting, this function is intended to allow a script or package to check that the setting is what it expects.
 
 
 
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined ''doLogin()'' function, a replacement for which is shown below.
 
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].
 
 
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 
 
 
Only one custom login text has been defined initially:
 
{| class="wikitable"
 
|+ Predefined custom login texts
 
|-
 
! Id !! Custom text !! Introduced in Mudlet version
 
|-
 
| 1 || "connect {character name} {password}" || TBD
 
|}
 
 
 
The addition of further texts would be subject to negotiation with the Mudlet Makers.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
+
local tblA = { 255, 0, 0 }
function doLogin()
+
local tblB = color_table.red
  if getCustomLoginTextId() ~= 1 then
+
local same = compare(tblA, tblB)
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
+
display(same)
    echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
+
-- this will return true
  else
+
display(tblA == tblB)
    tempTime(2.0, [[sendCustomLoginText()]], 1)
+
-- this will display false, as they are different tables
  end
+
-- even though they have the same value
end
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==loadMusicFile, PR #5799 merged ==
+
; Additional development notes
;loadMusicFile(settings table)
+
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)
:Loads music files from the Internet or the local file system to the "media" folder of the profile for later use with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]] and [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]]. Although files could be loaded directly at playing time from [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], loadMusicFile() provides the advantage of loading files in advance.
 
  
{| class="wikitable"
+
==createVideoPlayer, PR #6439==
! Required
+
;createVideoPlayer([name of userwindow], x, y, width, height)
! Key
 
! Value
 
! style="text-align:left;"| Purpose
 
|- style="color: green;"
 
| style="text-align:center;"| Yes
 
| name
 
| <file name>
 
| style="text-align:left;"|
 
* Name of the media file.
 
* May contain directory information (i.e. weather/lightning.wav).
 
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
 
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
 
|- style="color: blue;"
 
| style="text-align:center;"| Maybe
 
| url
 
| <url>
 
| style="text-align:left;"|
 
* Resource location where the media file may be downloaded.
 
* Only required if file to load is not part of the profile or on the local file system.
 
|-
 
|}
 
  
See also: [[Manual:Miscellaneous_Functions#playMusicFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[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]]
+
: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.
  
{{MudletVersion|4.15}}
+
{{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.
  
;Example
+
{{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.
  
<syntaxhighlight lang="lua">
+
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]]
---- Table Parameter Syntax ----
 
  
-- Download from the Internet
+
{{MudletVersion|4.??}}
loadMusicFile({
 
    name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
 
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
 
})
 
  
-- OR download from the profile
+
;Example
loadMusicFile({name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"})
+
<syntaxhighlight lang="lua">
 +
-- Create a 300x300 video player in the top-left corner of Mudlet
 +
createVideoPlayer(0,0,300,300)
  
-- OR download from the local file system
+
-- Alternative examples using Geyser.VideoPlayer
loadMusicFile({name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"})
+
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})
 +
 +
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({
 +
  name = "GUI.VideoPlayer",
 +
  x = "70%", y = 0, -- edit here if you want to move it
 +
  width = "30%", height = "50%"
 +
}, GUI.Right)
 
</syntaxhighlight>
 
</syntaxhighlight>
<syntaxhighlight lang="lua">
 
---- Ordered Parameter Syntax of loadMediaFile(name[, url]) ----
 
  
-- Download from the Internet
+
==loadVideoFile, PR #6439==
loadMusicFile(
+
;loadVideoFile(settings table) or loadVideoFile(name, [url])
    "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
+
: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.
    , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
 
)
 
  
-- OR download from the profile
+
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.
loadMusicFile(getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3")
 
 
 
-- OR download from the local file system
 
loadMusicFile("C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3")
 
</syntaxhighlight>
 
 
 
==loadSoundFile, PR #5799 merged ==
 
;loadSoundFile(settings table)
 
:Loads sound files from the Internet or the local file system to the "media" folder of the profile for later use with [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]] and [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]]. Although files could be loaded directly at playing time from [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], loadSoundFile() provides the advantage of loading files in advance.
 
  
 
{| class="wikitable"
 
{| class="wikitable"
! Required
+
!Required
! Key
+
!Key
! Value
+
!Value
! style="text-align:left;"| Purpose
+
! style="text-align:left;" |Purpose
 
|- style="color: green;"
 
|- style="color: green;"
| style="text-align:center;"| Yes
+
| style="text-align:center;" |Yes
| name
+
|name
| <file name>
+
|<file name>
| style="text-align:left;"|
+
| style="text-align:left;" |
* Name of the media file.
+
*Name of the media file.
* May contain directory information (i.e. weather/lightning.wav).
+
*May contain directory information (i.e. weather/maelstrom.mp4).
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
+
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
+
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")
 
|- style="color: blue;"
 
|- style="color: blue;"
| style="text-align:center;"| Maybe
+
| style="text-align:center;" |Maybe
| url
+
|url
| <url>
+
|<url>
| style="text-align:left;"|
+
| style="text-align:left;" |
* Resource location where the media file may be downloaded.
+
*Resource location where the media file may be downloaded.
* Only required if file to load is not part of the profile or on the local file system.
+
*Only required if file to load is not part of the profile or on the local file system.
 
|-
 
|-
 
|}
 
|}
  
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[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]]
+
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]]
  
{{MudletVersion|4.15}}
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
Line 225: Line 342:
  
 
-- Download from the Internet
 
-- Download from the Internet
loadSoundFile({
+
loadVideoFile({
     name = "cow.wav"
+
     name = "TextInMotion-VideoSample-1080p.mp4"
     , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
+
     , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 
})
 
})
  
 
-- OR download from the profile
 
-- OR download from the profile
loadSoundFile({name = getMudletHomeDir().. "/cow.wav"})
+
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})
  
 
-- OR download from the local file system
 
-- OR download from the local file system
loadSoundFile({name = "C:/Users/Tamarindo/Documents/cow.wav"})
+
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Ordered Parameter Syntax of loadSoundFile(name[,url]) ----
+
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----
  
 
-- Download from the Internet
 
-- Download from the Internet
loadSoundFile("cow.wav", "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/")
+
loadVideoFile(
 +
    "TextInMotion-VideoSample-1080p.mp4"
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
)
  
 
-- OR download from the profile
 
-- OR download from the profile
loadSoundFile(getMudletHomeDir().. "/cow.wav")
+
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")
  
 
-- OR download from the local file system
 
-- OR download from the local file system
loadSoundFile("C:/Users/Tamarindo/Documents/cow.wav")
+
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==playMusicFile, PR #5799 merged ==
+
==playVideoFile, PR #6439==
;playMusicFile(settings table)
+
;playVideoFile(settings table)
: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()]].
+
: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>.
  
 
{| class="wikitable"
 
{| class="wikitable"
! Required
+
!Required
! Key
+
!Key
! Value
+
!Value
! Default
+
!Default
! style="text-align:left;"| Purpose
+
! style="text-align:left;" |Purpose
 
|- style="color: green;"
 
|- style="color: green;"
| style="text-align:center;"| Yes
+
| style="text-align:center;" |Yes
| name
+
|name
| <file name>
+
|<file name>
| &nbsp;
+
|&nbsp;
| style="text-align:left;"|
+
| style="text-align:left;" |
* Name of the media file.
+
*Name of the media file.
* May contain directory information (i.e. weather/lightning.wav).
+
*May contain directory information (i.e. weather/maelstrom.mp4).
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
+
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
+
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
+
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
 
|-
 
|-
| style="text-align:center;"| No
+
| style="text-align:center;" |No
 
| volume
 
| volume
| 1 to 100
+
|1 to 100
| 50
+
|50
| style="text-align:left;"|
+
| style="text-align:left;" |
* Relative to the volume set on the player's client.
+
*Relative to the volume set on the player's client.
 
|-
 
|-
| style="text-align:center;"| No
+
| style="text-align:center;" |No
| fadein
+
|fadein
 
|<msec>
 
|<msec>
 
|
 
|
Line 289: Line 409:
 
|-
 
|-
 
| style="text-align:center;" |No
 
| style="text-align:center;" |No
| fadeout
+
|fadeout
 
|<msec>
 
|<msec>
 
|
 
|
Line 298: Line 418:
 
*1000 milliseconds = 1 second.
 
*1000 milliseconds = 1 second.
 
|-
 
|-
| style="text-align:center;"| No
+
| style="text-align:center;" |No
| start
+
|start
| <msec>
+
|<msec>
 
| 0
 
| 0
| style="text-align:left;"|
+
| style="text-align:left;" |
* Begin play at the specified position in milliseconds.
+
*Begin play at the specified position in milliseconds.
 
|-
 
|-
 
| style="text-align:center;" |No
 
| style="text-align:center;" |No
| loops
+
|loops
 
| -1, or >= 1
 
| -1, or >= 1
 
|1
 
|1
 
| style="text-align:left;" |
 
| style="text-align:left;" |
 
*Number of iterations that the media plays.
 
*Number of iterations that the media plays.
* A value of -1 allows the media to loop indefinitely.
+
*A value of -1 allows the media to loop indefinitely.
 
|-
 
|-
 
| style="text-align:center;" |No
 
| style="text-align:center;" |No
| key  
+
|key
 
|<key>
 
|<key>
 
|&nbsp;
 
|&nbsp;
Line 321: Line 441:
 
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 
|-
 
|-
| style="text-align:center;"| No
+
| style="text-align:center;" |No
| tag
+
|tag
| <tag>
+
|<tag>
| &nbsp;
+
|&nbsp;
| style="text-align:left;"|
+
| style="text-align:left;" |
* Helps categorize media.
+
*Helps categorize media.
 
|-
 
|-
 
| style="text-align:center;" |No
 
| style="text-align:center;" |No
| continue  
+
|continue
| true or false
+
|true or false
| true
+
|true
 +
| style="text-align:left;" |
 +
*Continues playing matching new video files when true.
 +
*Restarts matching new video files when false.
 +
|- style="color: blue;"
 +
| style="text-align:center;" |Maybe
 +
|url
 +
|<url>
 +
|&nbsp;
 
| style="text-align:left;" |
 
| style="text-align:left;" |
*Continues playing matching new music files when true.
+
*Resource location where the media file may be downloaded.
*Restarts matching new music files when false.
+
*Only required if the file is to be downloaded remotely or for streaming from the Internet.
 
|- style="color: blue;"
 
|- style="color: blue;"
| style="text-align:center;"| Maybe
+
| style="text-align:center;" |Maybe
| url
+
|stream
| <url>
+
|true or false
| &nbsp;
+
|false
| style="text-align:left;"|
+
| style="text-align:left;" |
* Resource location where the media file may be downloaded.
+
*Streams files from the Internet when true.
* Only required if the file is to be downloaded remotely.
+
*Download files when false (default).
 +
*Used in combination with the `url` key.
 
|-
 
|-
 
|}
 
|}
  
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]]
+
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]]
  
{{MudletVersion|4.15}}
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
Line 355: Line 484:
 
---- Table Parameter Syntax ----
 
---- Table Parameter Syntax ----
  
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
-- Stream a video file from the Internet and play it.
playMusicFile({
+
playVideoFile({
     name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
+
    name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
    , stream = true
 +
})
 +
 
 +
-- Play a video file from the Internet, storing it in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media) so you don't need to download it over and over.  You could add ", stream = false" below, but that is the default and is not needed.
 +
 
 +
playVideoFile({
 +
     name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
})
 +
 
 +
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
 +
playVideoFile({
 +
    name = "TextInMotion-VideoSample-1080p.mp4"
 
})
 
})
  
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory
+
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
 
---- [volume] of 75 (1 to 100)
 
---- [volume] of 75 (1 to 100)
playMusicFile({
+
playVideoFile({
     name = getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3"
+
     name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"
 
     , volume = 75
 
     , volume = 75
 
})
 
})
  
-- OR copy once from the local file system, and play a music file stored in the profile's media directory
+
-- OR copy once from the local file system, and play a video file stored in the profile's media directory
 
---- [volume] of 75 (1 to 100)
 
---- [volume] of 75 (1 to 100)
playMusicFile({
+
playVideoFile({
     name = "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3"
+
     name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"
 
     , volume = 75
 
     , volume = 75
 
})
 
})
  
-- OR download once from the Internet, and play music stored in the profile's media directory
+
-- OR download once from the Internet, and play a video stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds
+
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music
+
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
+
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "rugby" for stopping this unique music later
+
---- [key] reference of "text" for stopping this unique video later
---- [tag] reference of "ambience" to stop and music later with the same tag
+
---- [tag] reference of "ambience" to stop any video later with the same tag
---- [continue] playing this music if another request for the same music comes in (false restarts it)  
+
---- [continue] playing this video if another request for the same video comes in (false restarts it)  
---- [url] to download once from the Internet if the music does not exist in the profile's media directory
+
---- [url] resource location where the file may be accessed on the Internet
playMusicFile({
+
---- [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)
     name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"
+
playVideoFile({
 +
     name = "TextInMotion-VideoSample-1080p.mp4"
 
     , volume = nil -- nil lines are optional, no need to use
 
     , volume = nil -- nil lines are optional, no need to use
     , fadein = 20000
+
     , fadein = 10000
     , fadein = 53000
+
     , fadeout = 15000
     , start = 10000
+
     , start = 5000
 
     , loops = nil -- nil lines are optional, no need to use
 
     , loops = nil -- nil lines are optional, no need to use
     , key = "rugby"
+
     , key = "text"
 
     , tag = "ambience"
 
     , tag = "ambience"
 
     , continue = true
 
     , continue = true
     , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
+
     , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
    , stream = false
 
})
 
})
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Ordered Parameter Syntax of playMusicFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url]) ----
+
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----
  
-- Play a music file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
-- Stream a video file from the Internet and play it.
playMusicFile(
+
playVideoFile(
     "167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
+
    "TextInMotion-VideoSample-1080p.mp4"
 +
    , nil -- volume
 +
    , nil -- fadein
 +
    , nil -- fadeout
 +
    , nil -- start
 +
    , nil -- loops
 +
    , nil -- key
 +
     , nil -- tag
 +
    , true -- continue
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
 +
    , false -- stream
 
)
 
)
  
-- OR copy once from the game's profile, and play a music file stored in the profile's media directory
+
-- Play a video file from the Internet, storing it in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media) so you don't need to download it over and over.
 +
playVideoFile(
 +
    "TextInMotion-VideoSample-1080p.mp4"
 +
    , nil -- volume
 +
    , nil -- fadein
 +
    , nil -- fadeout
 +
    , nil -- start
 +
    , nil -- loops
 +
    , nil -- key
 +
    , nil -- tag
 +
    , true -- continue
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
 +
    , false -- stream
 +
)
 +
 
 +
-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
 +
playVideoFile(
 +
    "TextInMotion-VideoSample-1080p.mp4"  -- name
 +
)
 +
 
 +
-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
 
---- [volume] of 75 (1 to 100)
 
---- [volume] of 75 (1 to 100)
playMusicFile(
+
playVideoFile(
     getMudletHomeDir().. "/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
+
     getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name
 
     , 75 -- volume
 
     , 75 -- volume
 
)
 
)
  
-- OR copy once from the local file system, and play a music file stored in the profile's media directory
+
-- OR copy once from the local file system, and play a video file stored in the profile's media directory
 
---- [volume] of 75 (1 to 100)
 
---- [volume] of 75 (1 to 100)
playMusicFile(
+
playVideoFile(
     "C:/Users/Tamarindo/Documents/167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
+
     "C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name
 
     , 75 -- volume
 
     , 75 -- volume
 
)
 
)
  
-- OR download once from the Internet, and play music stored in the profile's media directory
+
-- OR download once from the Internet, and play a video stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 20 seconds
+
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
---- [fadeout] and decrease the volume from default volume to one, 53 seconds from the end of the music
+
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
---- [start] 10 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
+
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "rugby" for stopping this unique music later
+
---- [key] reference of "text" for stopping this unique video later
---- [tag] reference of "ambience" to stop and music later with the same tag
+
---- [tag] reference of "ambience" to stop any video later with the same tag
---- [continue] playing this music if another request for the same music comes in (false restarts it)  
+
---- [continue] playing this video if another request for the same video comes in (false restarts it)  
---- [url] to download once from the Internet if the music does not exist in the profile's media directory
+
---- [url] resource location where the file may be accessed on the Internet
playMusicFile(
+
---- [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)
     "167124__patricia-mcmillen__rugby-club-in-spain.mp3" -- name
+
playVideoFile(
 +
     "TextInMotion-VideoSample-1080p.mp4" -- name
 
     , nil -- volume
 
     , nil -- volume
     , 20000 -- fadein
+
     , 10000 -- fadein
     , 53000 -- fadeout
+
     , 15000 -- fadeout
     , 10000 -- start
+
     , 5000 -- start
 
     , nil -- loops
 
     , nil -- loops
     , "rugby" -- key  
+
     , "text" -- key
 
     , "ambience" -- tag
 
     , "ambience" -- tag
 
     , true -- continue
 
     , true -- continue
     , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url
+
     , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
 +
    , false -- stream
 
)
 
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==playSoundFile, PR #5799 merged ==
+
 
;playSoundFile(settings table)
+
==stopVideos, PR #6439==
: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()]].
+
;stopVideos(settings table)
 +
:Stop all videos (no filter), or videos that meet a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]].
  
 
{| class="wikitable"
 
{| class="wikitable"
! Required
+
!Required
! Key
+
!Key
! Value
+
!Value
! Default
+
! style="text-align:left;" |Purpose
! style="text-align:left;"| Purpose
+
|-
|- style="color: green;"
+
| style="text-align:center;" |No
| style="text-align:center;"| Yes
 
 
| name
 
| name
 
| <file name>
 
| <file name>
| &nbsp;
+
| style="text-align:left;" |
| style="text-align:left;"|
 
 
* Name of the media file.
 
* Name of the media file.
* May contain directory information (i.e. weather/lightning.wav).
 
* May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp3")
 
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp3")
 
* Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
 
|-
 
| style="text-align:center;"| No
 
| volume
 
| 1 to 100
 
| 50
 
| style="text-align:left;"|
 
* Relative to the volume set on the player's client.
 
|-
 
| style="text-align:center;"| No
 
| fadein
 
|<msec>
 
|
 
|
 
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.
 
*Start position:  Start of media.
 
*End position:  Start of media plus the number of milliseconds (msec) specified.
 
*1000 milliseconds = 1 second.
 
|-
 
| style="text-align:center;" |No
 
| fadeout
 
|<msec>
 
|
 
|
 
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.
 
*Start position:  End of the media minus the number of milliseconds (msec) specified.
 
*End position:  End of the media.
 
*1000 milliseconds = 1 second.
 
|-
 
| style="text-align:center;"| No
 
| start
 
| <msec>
 
| 0
 
| style="text-align:left;"|
 
*  Begin play at the specified position in milliseconds.
 
|-
 
| style="text-align:center;" |No
 
| loops
 
| -1, or >= 1
 
|1
 
| style="text-align:left;" |
 
*Number of iterations that the media plays.
 
* A value of -1 allows the media to loop indefinitely.
 
 
|-
 
|-
 
| style="text-align:center;" |No
 
| style="text-align:center;" |No
| key  
+
|key
 
|<key>
 
|<key>
|&nbsp;
 
 
| style="text-align:left;" |
 
| style="text-align:left;" |
 
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
 
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
 
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
|-
 
| style="text-align:center;"| No
 
| tag
 
| <tag>
 
| &nbsp;
 
| style="text-align:left;"|
 
* Helps categorize media.
 
 
|-
 
|-
 
| style="text-align:center;" |No
 
| style="text-align:center;" |No
| priority
+
|tag
| 1 to 100
+
|<tag>
|&nbsp;
 
 
| style="text-align:left;" |
 
| style="text-align:left;" |
*Halts the play of current or future played media files with a lower priority while this media plays.
+
*Helps categorize media.
|- style="color: blue;"
 
| style="text-align:center;"| Maybe
 
| url
 
| <url>
 
| &nbsp;
 
| style="text-align:left;"|
 
* Resource location where the media file may be downloaded.
 
* Only required if the file is to be downloaded remotely.
 
 
|-
 
|-
 
|}
 
|}
  
See also: [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
+
See also: [[Manual:Miscellaneous_Functions#loadSoundFile|loadSoundFile()]], [[Manual:Miscellaneous_Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous_Functions#loadVideoFile|loadVideoFile()]], [[Manual:Miscellaneous_Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous Functions#createVideoPlayer|createVideoPlayer()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
  
{{MudletVersion|4.15}}
+
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
Line 544: Line 657:
 
---- Table Parameter Syntax ----
 
---- Table Parameter Syntax ----
  
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
-- Stop all playing video files for this profile associated with the API
playSoundFile({
+
stopVideos()
    name = "cow.wav"
 
})
 
  
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory
+
-- Stop playing the text mp4 by name
---- [volume] of 75 (1 to 100)
+
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})
playSoundFile({
 
    name = getMudletHomeDir().. "/cow.wav"
 
    , volume = 75
 
})
 
  
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory
+
-- Stop playing the unique sound identified as "text"
---- [volume] of 75 (1 to 100)
+
stopVideos({
playSoundFile({
+
     name = nil -- nil lines are optional, no need to use
    name = "C:/Users/Tamarindo/Documents/cow.wav"
+
     , key = "text" -- key
    , volume = 75
+
     , tag = nil -- nil lines are optional, no need to use
})
 
 
 
-- OR download once from the Internet, and play a sound stored in the profile's media directory
 
---- [volume] of 75
 
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)
 
---- [key] reference of "cow" for stopping this unique sound later
 
---- [tag] reference of "animals" to stop a group of sounds later with the same tag
 
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)
 
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory
 
playSoundFile({
 
     name = "cow.wav"
 
    , volume = 75
 
    , fadein = nil -- nil lines are optional, no need to use
 
     , fadeout = nil -- nil lines are optional, no need to use
 
     , start = nil -- nil lines are optional, no need to use
 
    , loops = 2
 
    , key = "cow"
 
    , tag = "animals"
 
    , priority = 25
 
    , url = "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/"
 
 
})
 
})
 
</syntaxhighlight>
 
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Ordered Parameter Syntax of playSoundFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,priority][,url]) ----
+
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----
  
-- Play a sound file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
+
-- Stop all playing video files for this profile associated with the API
playSoundFile(
+
stopVideos()
     "cow.wav" -- name
+
 
 +
-- Stop playing the text mp4 by name
 +
stopVideos("TextInMotion-VideoSample-1080p.mp4")
 +
 
 +
-- Stop playing the unique sound identified as "text"
 +
stopVideos(
 +
     nil -- name
 +
    , "text" -- key
 +
    , nil -- tag
 
)
 
)
 +
</syntaxhighlight>
  
-- OR copy once from the game's profile, and play a sound file stored in the profile's media directory
 
---- [volume] of 75 (1 to 100)
 
playSoundFile(
 
    getMudletHomeDir().. "/cow.wav" -- name
 
    , 75 -- volume
 
)
 
  
-- OR copy once from the local file system, and play a sound file stored in the profile's media directory
+
==getCustomLoginTextId, PR #3952 open==
---- [volume] of 75 (1 to 100)
+
;getCustomLoginTextId()
playSoundFile(
+
 
    "C:/Users/Tamarindo/Documents/cow.wav" -- name
+
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.
    , 75 -- volume
+
 
)
+
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined ''doLogin()'' function, a replacement for which is shown below.
 +
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].
 +
 
 +
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 +
 
 +
Only one custom login text has been defined initially:
 +
{| class="wikitable"
 +
|+Predefined custom login texts
 +
|-
 +
!Id!!Custom text!!Introduced in Mudlet version
 +
|-
 +
|1||"connect {character name} {password}"||TBD
 +
|}
 +
 
 +
The addition of further texts would be subject to negotiation with the Mudlet Makers.
  
-- OR download once from the Internet, and play a sound stored in the profile's media directory
+
;Example
---- [volume] of 75
+
<syntaxhighlight lang="lua">
---- [loops] of 2 (-1 for indefinite repeats, 1+ for finite repeats)
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
---- [key] reference of "cow" for stopping this unique sound later
+
function doLogin()
---- [tag] reference of "animals" to stop a group of sounds later with the same tag
+
  if getCustomLoginTextId() ~= 1 then
---- [priority] of 25 (1 to 100, 50 default, a sound with a higher priority would stop this one)
+
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
---- [url] to download once from the Internet if the sound does not exist in the profile's media directory
+
    echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
playSoundFile(
+
  else
    "cow.wav" -- name
+
     tempTime(2.0, [[sendCustomLoginText()]], 1)
    , 75 -- volume
+
  end
     , nil -- fadein
+
end
    , nil -- fadeout
 
    , nil -- start
 
    , 2 -- loops
 
    , "cow" -- key
 
    , "animals" -- tag
 
    , 25 -- priority
 
    , "https://raw.githubusercontent.com/StickMUD/StickMUDSounds/master/sounds/" -- url
 
)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==sendCharacterName, PR #3952 open ==
+
==sendCharacterName, PR #3952 open==
 
;sendCharacterName()
 
;sendCharacterName()
  
Line 642: Line 738:
  
 
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.
 
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined ''doLogin()'' function, reproduced below, that may be replaced for more sophisticated requirements.
: See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]], [[#sendCharacterName|sendCharacterName()]].
  
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
Line 657: Line 753:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== sendCustomLoginText, PR #3952 open ==
+
==sendCustomLoginText, PR #3952 open ==
 
;sendCustomLoginText()
 
;sendCustomLoginText()
  
Line 663: Line 759:
  
 
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.
 
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined ''doLogin()'' function, a replacement for which is shown below.
: See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
+
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendPassword|sendPassword()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
  
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
Line 671: Line 767:
 
|+Predefined custom login texts
 
|+Predefined custom login texts
 
|-
 
|-
!Id!!Custom text!! Introduced in Mudlet version
+
!Id!!Custom text!!Introduced in Mudlet version
 
|-
 
|-
 
|1||"connect {character name} {password}"||TBD
 
|1||"connect {character name} {password}"||TBD
Line 691: Line 787:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==stopMusic, PR #5799 merged ==
+
=Mudlet Object Functions=
;stopMusic(settings table)
+
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.
:Stop all music (no filter), or music that meets a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]].
 
  
{| class="wikitable"
+
==ancestors, new in PR #6726==
! Required
+
;ancestors(IDnumber, type)
! Key
+
:You can use this function to find out about all the ancestors of something.
! Value
+
 
! style="text-align:left;"| Purpose
+
:Returns a list as a table with the details of each successively distance ancestor (if any) of the given item; the details are in the form of a sub-table, within each containing specifically:
|-
+
:* its IDnumber as a number
| style="text-align:center;"| No
+
:* its name as a string
| name
+
:* whether it is active as a boolean
| <file name>
+
:* its "node" (type) as a string, one of "item", "group" (folder) or "package" (module)
| style="text-align:left;"|
+
:Returns ''nil'' and an error message if either parameter is not valid
* Name of the media file.
 
|-
 
| style="text-align:center;" |No
 
| key
 
|<key>
 
| style="text-align:left;" |
 
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
 
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 
|-
 
| style="text-align:center;"| No
 
| tag
 
| <tag>
 
| style="text-align:left;"|
 
* Helps categorize media.
 
|-
 
|}
 
  
See also: [[Manual:Miscellaneous_Functions#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]]
+
;Parameters
 +
* ''IDnumber:''
 +
: The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
: The type can be 'alias', 'button', 'trigger', 'timer', 'keybind', or 'script'.
  
{{MudletVersion|4.15}}
+
: See also: [[#isAncestorsActive|isAncestorsActive(...)]], [[#isActive|isActive(...)]]
  
 
;Example
 
;Example
 +
<syntaxhighlight lang="lua">
 +
-- To do
 +
</syntaxhighlight>
  
<syntaxhighlight lang="lua">
+
==findItems, new in PR #6742==
---- Table Parameter Syntax ----
+
;findItems("name", "type"[, exact[, case sensitive]])
 +
: You can use this function to determine the ID number or numbers of items of a particular type with a given name.
 +
 
 +
:Returns a list as a table with ids of each Mudlet item that matched or ''nil'' and an error message should an incorrect type string be given.
  
-- Stop all playing music files for this profile associated with the API
+
;Parameters
stopMusic()
+
* ''name:''
 +
:The name (as a string) of the item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
:The type (as a string) can be 'alias', 'button', 'trigger', 'timer', 'keybind' , or 'script'.
 +
* ''exact:''
 +
:(Optional) a boolean which if omitted or ''true'' specifies to match the given name against the whole of the names for items or only as a sub-string of them. As a side effect, if this is provided and is ''false'' and an empty string (i.e. ''""'') is given as the first argument then the function will return the ID numbers of ''all'' items (both temporary and permanent) of the given type in existence at the time.
 +
* ''case sensitive:''
 +
:(Optional) a boolean which if omitted or ''true'' specifies to match in a case-sensitive manner the given name against the names for items.
  
-- Stop playing the rugby mp3 by name
+
;Example
stopMusic({name = "167124__patricia-mcmillen__rugby-club-in-spain.mp3"})
+
Given a profile with just the default packages installed (automatically) - including the '''echo''' one:
 +
[[File:View of standard aliases with focus on echo package.png|border|none|400px|link=]]
  
-- Stop playing the unique sound identified as "rugby"
 
stopMusic({
 
    name = nil  -- nil lines are optional, no need to use
 
    , key = "rugby" -- key
 
    , tag = nil  -- nil lines are optional, no need to use
 
})
 
</syntaxhighlight>
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Ordered Parameter Syntax of stopMusic([name][,key][,tag]) ----
+
-- Should find just the package with the name:
 +
lua findItems("echo", "alias")
 +
{ 3 }
  
-- Stop all playing music files for this profile associated with the API
+
-- Should find both the package and the alias - as the latter contains "echo" with another character
stopMusic()
+
lua findItems("echo", "alias", false)
 +
{ 3, 4 }
  
-- Stop playing the rugby mp3 by name
+
-- Finds the ID numbers of all the aliases:
stopMusic("167124__patricia-mcmillen__rugby-club-in-spain.mp3")
+
lua findItems("", "alias", false)
 +
{ 1, 2, 3, 4, 5, 6, 7 }
  
-- Stop playing the unique sound identified as "rugby"
+
-- Will still find the package with the name "echo" as we are not concerned with the casing now:
stopMusic(
+
lua findItems("Echo", "alias", true, false)
    nil -- name
+
{ 3 }
    , "rugby" -- key
+
 
    , nil -- tag
+
-- Won't find the package with the name "echo" now as we are concerned with the casing:
)
+
lua findItems("Echo", "alias", true, true)
 +
{}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==stopSounds, PR #5799 merged ==
+
==getExitStubsNames, new in PR #7519==
;stopSounds(settings table)
+
;table = getExitStubsNames(roomid)
: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()]].
 
  
{| class="wikitable"
+
:Returns a table of directions that have an exit stub marked in them. Returns nil plus error message of called on a non-existent room.
! Required
 
! Key
 
! Value
 
! style="text-align:left;"| Purpose
 
|-
 
| style="text-align:center;"| No
 
| name
 
| <file name>
 
| style="text-align:left;"|
 
* Name of the media file.
 
|-
 
| style="text-align:center;" |No
 
| key
 
|<key>
 
| style="text-align:left;" |
 
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
 
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 
|-
 
| style="text-align:center;"| No
 
| tag
 
| <tag>
 
| style="text-align:left;"|
 
* Helps categorize media.
 
|-
 
| style="text-align:center;" |No
 
| priority
 
| 1 to 100
 
| style="text-align:left;" |
 
*Halts the play of current or future played media files with a matching or lower priority.
 
|-
 
|}
 
 
 
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]]
 
  
{{MudletVersion|4.15}}
+
: See also: [[#setExitStub|setExitStub()]], [[#connectExitStub|connectExitStub()]], [[#getExitStubs|getExitStubs()]], [[#getExitStubs1|getExitStubs1()]]
  
 
;Example
 
;Example
 +
<syntaxhighlight lang="lua">
 +
-- show the exit stubs in room 6 as direction names
 +
local directions = getExitStubsNames(6)
 +
for i = 1, #directions do print(directions[i]) end
 +
-- will return a table such as
 +
{ "north", "south", "up", "in" }
 +
</syntaxhighlight>
  
<syntaxhighlight lang="lua">
+
==getProfiles, new in PR #7423==
---- Table Parameter Syntax ----
+
;getProfiles()
  
-- Stop all playing sound files for this profile associated with the API
+
:Return a table containing some basic information about the game profiles available to Mudlet.  The key is the profile name and values can be <code>host</code>, <code>port</code>, <code>loaded</code>, and <code>connected</code>.
stopSounds()
 
  
-- Stop playing the cow sound
+
* <code>host</code> is the hostname or IP of the server
stopSounds({name = "cow.wav"})
+
* <code>port</code> is the port of the server
 +
* <code>loaded</code> means the profile is open and can be edited, true if loaded, false otherwise
 +
* <code>connected</code> means the profile is connected to the game server (ie. playing), true if connected, false or nil otherwise
  
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50
+
;Example
---- This would not stop sounds tagged as "animals" greater than priority 50.  This is an "AND" and not an "OR".
 
stopSounds({
 
    name = nil -- nil lines are optional, no need to use
 
    , key = nil -- nil lines are optional, no need to use
 
    , tag = "animals"
 
    , priority = 50
 
})
 
</syntaxhighlight>
 
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
---- Ordered Parameter Syntax of stopSounds([name][,key][,tag][,priority]) ----
+
local profiles = getProfiles()
 +
display(profiles)
  
-- Stop all playing sound files for this profile associated with the API
+
--output
stopSounds()
+
{
 
+
  ["Abandoned Realms"] = {
-- Stop playing the cow sound
+
    host = "abandonedrealms.com",
stopSounds("cow.wav")
+
    loaded = false,
 
+
    port = "9000"
-- Stop playing any sounds tagged as "animals" with a priority less than or equal to 50
+
  },
---- This would not stop sounds tagged as "animals" greater than priority 50.  This is an "AND" and not an "OR".
+
  FieryMUD = {
stopSounds(
+
     connected = true,
     nil -- name
+
     host = "fierymud.org",
     , nil -- key
+
     loaded = true,
     , "animals" -- tag
+
    port = "4000"
    , 50 -- priority
+
  }
)
+
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=Mudlet Object Functions=
+
==isActive, modified by PR #6726==
:A collection of functions that manipulate Mudlets scripting objects - triggers, aliases, and so forth.
+
;isActive(name/IDnumber, type[, checkAncestors])
 +
:You can use this function to check if something, or somethings, are active.  
  
== getProfileStats PR 5706 ==
+
:Returns the number of active things - and 0 if none are active. Beware that all numbers are true in Lua, including zero.
;getProfileStats()
 
  
:Returns a table with profile statistics for how many triggers, aliases, keys, timers, and scripts the profile has. Similar to the Statistics button in the script editor, accessible to Lua scripting.
+
;Parameters
 +
* ''name:''
 +
:The name (as a string) or, from '''Mudlet 4.17.0''', the ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
:The type can be 'alias', 'button' (from '''Mudlet 4.10'''), 'trigger', 'timer', 'keybind' (from '''Mudlet 3.2'''), or 'script' (from '''Mudlet 3.17''').
 +
* ''checkAncestors:''
 +
:(Optional) If provided AND ''true'' (considered ''false'' if absent to reproduce behavior of previous versions of Mudlet) then this function will only count an item as active if it '''and''' all its parents (ancestors) are active (from '''Mudlet tbd''').
  
{{MudletVersion|4.15}}
+
:See also: [[#exists|exists(...)]], [[#isAncestorsActive|isAncestorsActive(...)]], [[#ancestors|ancestors(...)]]
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- show all stats
+
echo("I have " .. isActive("my trigger", "trigger") .. " currently active trigger(s) called 'my trigger'!")
display(getProfileStats())
 
  
-- check how many active triggers there are
+
-- Can also be used to check if a specific item is enabled or not.
activetriggers = getProfileStats().triggers.active
+
if isActive("spellname", "trigger") > 0 then
cecho(f"<PaleGreen>We have <SlateGrey>{activetriggers}<PaleGreen> active triggers!\n")
+
  -- the spellname trigger is active
 +
else
 +
  -- it is not active
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=Networking Functions=
+
{{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.
:A collection of functions for managing networking.
 
 
 
=String Functions=
 
:These functions are used to manipulate strings.
 
 
 
==cecho2string, PR#5881 merged==
 
; plainText = cecho2string(formattedText)
 
 
 
:Strips the text formatting from the string passed in, leaving behind only the text.
 
  
;See also: [[Manual:Lua_Functions#ansi2string|ansi2string()]], [[Manual:Lua_Functions#hecho2string|hecho2string()]]
+
==isAncestorsActive, new in PR #6726==
 +
;isAncestorsActive(IDnumber, "type")
 +
:You can use this function to check if '''all''' the ancestors of something are active independent of whether it itself is, (for that use the two argument form of [[#isActive|isActive(...)]]).
  
{{MudletVersion|4.16}}
+
:Returns ''true'' if all (if any) of the ancestors of the item with the specified ID number and type are active, if there are no such parents then it will also returns ''true''; otherwise returns ''false''. In the event that an invalid type string or item number is provided returns ''nil'' and an error message.
  
 
;Parameters
 
;Parameters
* ''formattedText:''
+
* ''IDnumber:''
: The string you want to strip the formatting codes from
+
:The ID number of a single item, (which will be that returned by a ''temp*'' or ''perm*'' function to create such an item to identify the item).
 +
* ''type:''
 +
:The type can be 'alias', 'button', 'trigger', 'timer', 'keybind' or 'script' to define which item type is to be checked.
  
;Returns
+
:See also: [[#exists|exists(...)]]
* The string with the formatting codes stripped out.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local exampleString = "<red>Formatted <b>string</b>"
+
-- To do
local plainText = cecho2string(exampleString)
 
-- "Formatted string"
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==decho2string, PR#5881 merged==
+
==loadProfile, new in PR #7423==
; plainText = decho2string(formattedText)
+
;loadProfile(name, offline)
 +
:Load a profile, same as clicking the profile icon in the Profile Manager.
  
:Strips the text formatting from the string passed in, leaving behind only the text.
+
:Returns ''nil'' and an error message if either parameter is not valid.
 
 
;See also: [[Manual:Lua_Functions#ansi2string|ansi2string()]], [[Manual:Lua_Functions#cecho2string|cecho2string()]]
 
 
 
{{MudletVersion|4.16}}
 
  
 
;Parameters
 
;Parameters
* ''formattedText:''
+
* ''name:''
: The string you want to strip the formatting codes from
+
: The profile name to open, as identified in the Profile Manager.
 
+
* ''offline:''
;Returns
+
: true - load the profile but do not connect to the game, false - load the profile and connect to the game
* The string with the formatting codes stripped out.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local exampleString = "<255,0,0>Formatted <b>string</b>"
+
-- load and connect to the Archaea profile
local plainText = decho2string(exampleString)
+
loadProfile("Archaea", false)
-- "Formatted string"
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hecho2string, PR#5881 merged==
+
== clearProfileInformation(), new in PR #7511==
; plainText = hecho2string(formattedText)
+
;clearProfileInformation(text)
 +
:Clears the information text as displayed in the Profile Connection Window.  If this is a prepackaged game the text is reverted to the default text.
  
:Strips the text formatting from the string passed in, leaving behind only the text.
+
:See also: [[#getProfileInformation|getProfileInformation()]], [[#setProfileInformation|setProfileInformation()]]
  
;See also: [[Manual:Lua_Functions#ansi2string|ansi2string()]], [[Manual:Lua_Functions#decho2string|decho2string()]]
+
;Example
 +
<syntaxhighlight lang="lua">
 +
clearProfileInformation()
 +
</syntaxhighlight>
  
{{MudletVersion|4.16}}
+
== getProfileInformation(), new in PR #7511==
 +
;getProfileInformation()
 +
:Return a string containing the information text as displayed in the Profile Connection Window.
  
;Parameters
+
:See also: [[#clearProfileInformation|clearProfileInformation()]], [[#setProfileInformation|setProfileInformation()]]
* ''formattedText:''
 
: The string you want to strip the formatting codes from
 
 
 
;Returns
 
* The string with the formatting codes stripped out.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local exampleString = "#ff0000Formatted #bstring#/b"
+
echo(getProfileInformation())
local plainText = cecho2string(exampleString)
 
-- "Formatted string"
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== string.patternEscape, utf8.patternEscape PR 5806==
+
== setProfileInformation(), new in PR #7511==
;escapedString = string.patternEscape(str) or escapedString = utf8.patternEscape(str)
+
;setProfileInformation(text)
 
+
:Set the information text as displayed in the Profile Connection Window. Returns nil and an error messages if no string is supplied.
:Returns a version of str with all Lua pattern characters escaped to ensure string.match/find/etc look for the original str.
 
 
 
;See also:[[Manual:Lua_Functions#string.trim|string.trim()]], [[Manual:Lua_Functions#string.genNocasePattern|string.genNocasePattern()]]
 
 
 
{{MudletVersion|4.15}}
 
  
;Parameters
+
:See also: [[#clearProfileInformation|clearProfileInformation()]], [[#getProfileInformation|getProfileInformation()]]
*''str:''
 
:The string to escape lua pattern characters in.
 
 
 
;Returns
 
*The string with all special Lua pattern characters escaped.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- searching for a url inside of a string.
+
setProfileInformation("Elf warrior, lvl 15")
local helpString = [[
 
This feature can be accessed by going to https://some-url.com/athing.html?param=value and
 
retrieving the result!
 
]]
 
local url = "https://some-url.com/"
 
display(helpString:find(url))
 
-- nil
 
display(helpString:find(string.patternEscape(url)))
 
-- 42
 
-- 62
 
display(url:patternEscape())
 
-- "https://some%-url%.com/"
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=Table Functions=
+
=Networking Functions=
:These functions are used to manipulate tables. Through them you can add to tables, remove values, check if a value is present in the table, check the size of a table, and more.
+
:A collection of functions for managing networking.
 +
==sendSocket revised in PR #7066 (Open)==
 +
 
 +
;sendSocket(data)
  
=Text to Speech Functions =
+
: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.
:These functions are used to create sound from written words. Check out our [[Special:MyLanguage/Manual:Text-to-Speech|Text-To-Speech Manual]] for more detail on how this all works together.
 
  
=UI Functions=
+
; success = sendSocket("data")
: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.
 
  
==ansi2decho PR# 5670 merge, PR5719 merged==
+
;See also: [[Manual:Lua_Functions#feedTelnet|feedTelnet()]], [[Manual:Lua_Functions#feedTriggers|feedTriggers()]]
;ansi2decho(text, default_colour)
 
:Converts ANSI colour sequences in <code>text</code> to colour tags that can be processed by the decho() function.
 
:See also: [[Manual:Lua_Functions#decho|decho()]]
 
  
{{MudletVersion|3.0}}
+
{{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()]].
{{note}} ANSI bold is available since Mudlet 3.7.1+.
 
  
{{note}} underline, italics, overline, and strikethrough supported since Mudlet 4.15+
+
{{note}} The data (as bytes) once the tokens have been converted to their byte values is sent as is to the Game Server; any encoding to, say, a UTF-8 representation or to duplicate ''0xff'' byte values so they are not considered to be Telnet ''<IAC>'' (Interpret As Command) bytes must be done to the data prior to calling this function.
  
 
;Parameters
 
;Parameters
*''text:''
+
* ''data:''
:String that contains ANSI colour sequences that should be replaced.
+
: String containing the bytes to send to the Game Server possibly containing some tokens that are to be converted to bytes as well.
*''default_colour:''
 
:Optional - ANSI default colour code (used when handling orphan bold tags).
 
  
; Return values
+
;Returns
*''string text:''
+
* (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.
:The decho-valid converted text.
 
*''string colour:''
 
:The ANSI code for the last used colour in the substitution (useful if you want to colour subsequent lines according to this colour).
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local replaced = ansi2decho('\27[0;1;36;40mYou say in a baritone voice, "Test."\27[0;37;40m')
+
-- 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!
-- 'replaced' should now contain <r><0,255,255:0,0,0>You say in a baritone voice, "Test."<r><192,192,192:0,0,0>
+
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
decho(replaced)
+
-- comments up top should introduce / explain what it does
</syntaxhighlight>
+
 
 +
local something = function(exampleValue)
 +
if something then
 +
  -- do something with something (assuming there is a meaningful return value)
 +
end
 +
 
 +
-- maybe another example for the optional second case
 +
local somethingElse = function(exampleValue, anotherValue)
  
Or show a complete colourful squirrel! It's a lotta code to do all the colours, so click the '''Expand''' button on the right to show it:
+
-- lastly, include an example with error handling to give an idea of good practice
<div class="toccolours mw-collapsible mw-collapsed">
+
local ok, err = function()
<syntaxhighlight lang="lua">
+
if not ok then
decho(ansi2decho([[
+
   debugc(f"Error: unable to do <particular thing> because {err}\n")
                                                  �[38;5;95m▄�[48;5;95;38;5;130m▄▄▄�[38;5;95m█�[49m▀�[0m    �[0m
+
   return
╭───────────────────────╮          �[38;5;95m▄▄�[0m          �[38;5;95m▄�[48;5;95;38;5;130m▄▄�[48;5;130m█�[38;5;137m▄�[48;5;137;38;5;95m▄�[49m▀�[0m      �[0m
+
end
│                      │        �[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95m▄�[49;38;5;95m▄▄▄�[48;5;95;38;5;137m▄▄▄�[49;38;5;95m▄▄�[48;5;95;38;5;130m▄�[48;5;130m███�[38;5;137m▄�[48;5;137m█�[48;5;95;38;5;95m█�[0m      �[0m
 
│  Encrypt everything!  │      �[38;5;95m▄�[48;5;187;38;5;16m▄�[48;5;16;38;5;187m▄�[38;5;16m█�[48;5;137;38;5;137m███�[38;5;187m▄�[38;5;16m▄▄�[38;5;137m██�[48;5;95;38;5;95m█�[48;5;130;38;5;130m█████�[48;5;137;38;5;137m██�[48;5;95;38;5;95m█�[0m      �[0m
 
│                      ├────  �[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;16m▄▄▄�[48;5;137m███�[48;5;16;38;5;16m█�[48;5;187m▄�[48;5;16m█�[48;5;137;38;5;137m█�[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[0m      �[0m
 
╰───────────────────────╯      �[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;16m▄�[38;5;16m█�[38;5;137m▄�[48;5;137m██████�[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95m▄�[49;38;5;95m▄�[0m    �[0m
 
                                �[38;5;95m▀�[48;5;137m▄�[38;5;137m███████�[38;5;95m▄�[49m▀�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95m▄�[49;38;5;95m▄�[0m   �[0m
 
                                  �[48;5;95;38;5;187m▄▄▄�[38;5;137m▄�[48;5;137m██�[48;5;95;38;5;95m█�[0m    �[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[48;5;137;38;5;137m███�[48;5;95m▄�[49;38;5;95m▄�[0m  �[0m
 
                                �[38;5;187m▄�[48;5;187m███�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m  �[48;5;95;38;5;95m█�[48;5;130;38;5;130m█████████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[0m �[0m
 
                                �[38;5;187m▄�[48;5;187m███�[38;5;137m▄�[48;5;137m█�[48;5;95;38;5;95m█�[48;5;137;38;5;137m███�[48;5;95m▄�[49;38;5;95m▄�[0m  �[38;5;95m▀�[48;5;130m▄�[38;5;130m███████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
 
                              �[48;5;95;38;5;95m█�[48;5;187;38;5;187m████�[48;5;137;38;5;137m██�[48;5;95m▄�[48;5;137;38;5;95m▄�[38;5;137m██�[38;5;95m▄�[38;5;137m█�[48;5;95m▄�[49;38;5;95m▄�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
 
                              �[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;187;38;5;187m████�[48;5;137;38;5;137m███�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██�[48;5;95m▄�[49;38;5;95m▄�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
 
                          �[38;5;95m▄�[48;5;95m██�[48;5;137m▄▄�[48;5;187;38;5;187m████�[48;5;137;38;5;95m▄▄�[48;5;95;38;5;137m▄�[48;5;137m█�[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;137m████�[48;5;95;38;5;95m█�[0m �[48;5;95;38;5;95m█�[48;5;130;38;5;130m██████�[48;5;137;38;5;137m████�[48;5;95;38;5;95m█�[0m�[0m
 
                                �[48;5;187;38;5;187m███�[48;5;95m▄�[38;5;137m▄▄▄▄�[48;5;137m██████�[48;5;95;38;5;95m█�[49m▄�[48;5;95;38;5;130m▄�[48;5;130m██████�[48;5;137;38;5;137m███�[38;5;95m▄�[49m▀�[0m�[0m
 
                                �[48;5;187;38;5;95m▄�[38;5;187m████�[48;5;137;38;5;137m█�[38;5;95m▄�[48;5;95;38;5;137m▄�[48;5;137m█████�[48;5;95;38;5;95m█�[48;5;130;38;5;130m███████�[38;5;137m▄�[48;5;137m████�[48;5;95;38;5;95m█�[0m �[0m
 
                                �[48;5;95;38;5;95m█�[48;5;187;38;5;137m▄�[38;5;187m███�[48;5;95;38;5;95m█�[48;5;137;38;5;137m██████�[48;5;95m▄▄�[48;5;130m▄▄▄▄▄�[48;5;137m██████�[48;5;95;38;5;95m█�[0m  �[0m
 
                              �[38;5;95m▄▄▄�[48;5;95;38;5;137m▄�[48;5;187m▄�[38;5;187m██�[48;5;95m▄�[48;5;137;38;5;95m▄�[38;5;137m█████�[38;5;95m▄�[38;5;137m███████████�[48;5;95;38;5;95m█�[0m   �[0m
 
                            �[38;5;95m▀▀▀▀▀▀▀▀�[48;5;187m▄▄▄�[48;5;95;38;5;137m▄�[48;5;137m██�[38;5;95m▄�[49m▀�[0m �[38;5;95m▀▀�[48;5;137m▄▄▄▄▄▄�[49m▀▀▀�[0m    �[0m
 
                                  �[38;5;95m▀▀▀▀▀▀▀▀▀�[0m                �[0m
 
                                                                    ]]))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
</div>
 
  
[[File:Squirrel-in-Mudlet.png|frameless]]
+
; Additional development notes
 +
-- This function is still being written up.
  
==cecho PR #5669 merged, PR5719 merged, PR5751 merged==
+
==feedTelnet added in PR #7066 (Open)====
; cecho([window], text)
 
:Echoes text that can be easily formatted with colour, italics, bold, strikethrough, and underline tags. You can also include unicode art in it - try some examples from [http://1lineart.kulaone.com/#/ 1lineart].
 
:See also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#hecho|hecho()]], [[Manual:UI Functions#creplaceLine|creplaceLine()]]
 
  
{{Note}} Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you cecho it will erase any previous echo sent to the label.
+
; feedTelnet(data)
  
;Parameters
+
: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.
*''window:''
 
:Optional - the window name to echo to - can either be none or "main" for the main window, or a miniconsole, userwindow, or label name.
 
*''text:''
 
:The text to display, with color names inside angle brackets <>, ie ''<red>''. If you'd like to use a background color, put it after a colon : - ''<:red>''. You can use the ''<reset''> tag to reset to the default color. You can select any from this list: [[File:ShowColors.png|50px|frameless|Color Table]]
 
  
;Example
+
;See also: [[Manual:Lua_Functions#feedTriggers|feedTriggers()]], [[Manual:Lua_Functions#sendSocket|sendSocket()]]
<syntaxhighlight lang="lua">
 
cecho("Hi! This text is <red>red, <blue>blue, <green> and green.")
 
  
cecho("<:green>Green background on normal foreground. Here we add an <ivory>ivory foreground.")
+
{{MudletVersion|tbd}}
  
cecho("<blue:yellow>Blue on yellow text!")
+
{{note}} This is not really intended for end-user's but might be useful in some circumstances.
  
cecho("\n<red>Red text with <i>italics</i>, <u>underline</u>, <s>strikethrough</s>, <o>overline</o>, and <b>bold</b>.")
+
;Parameters
 +
* ''data''
 +
: String containing the bytes to send to the internal telnet engine as if it had come from the Game Server, it can containing some tokens listed below that are to be converted to bytes as well.
  
cecho("\n<green><o><u>Green text with over and underline at the same time.</o></u>")
+
;Returns
 +
* Boolean ''true'' if the ''data'' string was sent to the internal telnet engine. ''nil'' and an error message otherwise, specifically the case when there is some traces of a connection or a complete connection to the socket that passes the data to and from the game server. Additionally, if the data is an empty string ''""'' a second return value will be provided as an integer number representing a version for the table of tokens - which will be incremented each time a change is made to that table so that which tokens are valid can be determined. Note that unrecognised tokens should be passed through as is and not get replaced.
  
-- \n adds a new line
+
{| class="wikitable sortable"
cecho("<red>one line\n<green>another line\n<blue>last line")
+
|+ Token value table
 +
|-
 +
! Token !! Byte !! Version!! Notes
 +
|-
 +
|| <00> || \0x00 || 1 || 0 dec.
 +
|-
 +
|| <O_BINARY> || \0x00 || 1 || Telnet option: Binary
 +
|-
 +
|| <NUL> || \0x00 || 1 || ASCII control character: NULL
 +
|-
 +
|| <01> || \x01 || 1 || 1 dec.
 +
|-
 +
|| <O_ECHO> || \x01 || 1 || Telnet option: Echo
 +
|-
 +
|| <SOH> || \x01 || 1 || ASCII control character: Start of Heading
 +
|-
 +
|| <02> || \x02 || 1 || 2 dec. Telnet option: Reconnect
 +
|-
 +
|| <STX> || \x02 || 1 || ASCII control character: Start of Text
 +
|-
 +
|| <03> || \x03 || 1 || 3 dec.
 +
|-
 +
|| <O_SGA> || \x03 || 1 || Telnet option: Suppress Go Ahead
 +
|-
 +
|| <ETX> || \x03 || 1 || ASCII control character: End of Text
 +
|-
 +
|| <04> || \x04 || 1 || Telnet option: Approx Message Size Negotiation
 +
|-
 +
|| <EOT> || \x04 || 1 || ASCII control character: End of Transmission
 +
|-
 +
|| <05> || \x05 || 1 ||
 +
|-
 +
|| <O_STATUS> || \x05 || 1 ||
 +
|-
 +
|| <ENQ> || \x05 || 1 || ASCII control character: Enquiry
 +
|-
 +
|| <06> || \x06 || 1 || Telnet option: Timing Mark
 +
|-
 +
|| <ACK> || \x06 || 1 || ASCII control character: Acknowledge
 +
|-
 +
|| <07> || \x07 || 1 || Telnet option: Remote Controlled Trans and Echo
 +
|-
 +
|| <BELL> || \x07 || 1 || ASCII control character: Bell
 +
|-
 +
|| <08> || \x08 || 1 || Telnet option: Output Line Width
 +
|-
 +
|| <BS> || \x08 || 1 ||
 +
|-
 +
|| <09> || \x09 || 1 || Telnet option: Output Page Size
 +
|-
 +
|| <HTAB> || \x09 || 1 || ASCII control character: Horizontal Tab
 +
|-
 +
|| <0A> || \x0a || 1 || Telnet option: Output Carriage-Return Disposition
 +
|-
 +
|| <LF> || \x0a || 1 || ASCII control character: Line-Feed
 +
|-
 +
|| <0B> || \x0b || 1 || Telnet option: Output Horizontal Tab Stops
 +
|-
 +
|| <VTAB> || \x0b || 1 || ASCII control character: Vertical Tab
 +
|-
 +
|| <0C> || \x0c || 1 || Telnet option: Output Horizontal Tab Disposition
 +
|-
 +
|| <FF> || \x0c || 1 || ASCII control character: Form-Feed
 +
|-
 +
|| <0D> || \x0d || 1 || Telnet option: Output Form-feed Disposition
 +
|-
 +
|| <CR> || \x0d || 1 || ASCII control character: Carriage-Return
 +
|-
 +
|| <0E> || \x0e || 1 || Telnet option: Output Vertical Tab Stops
 +
|-
 +
|| <SO> || \x0e || 1 || ASCII control character: Shift-Out
 +
|-
 +
|| <0F> || \x0f || 1 || Telnet option: Output Vertical Tab Disposition
 +
|-
 +
|| <SI> || \x0f || 1 || ASCII control character: Shift-In
 +
|-
 +
|| <10> || \x10 || 1 || Telnet option: Output Linefeed Disposition
 +
|-
 +
|| <DLE> || \x10 || 1 || ASCII control character: Data Link Escape
 +
|-
 +
|| <11> || \x11 || 1 || Telnet option: Extended ASCII
 +
|-
 +
|| <DC1> || \x11 || 1 || ASCII control character: Device Control 1
 +
|-
 +
|| <12> || \x12 || 1 || Telnet option: Logout
 +
|-
 +
|| <DC2" || \x12 || 1 || ASCII control character: Device Control 2
 +
|-
 +
|| <13> || \x13 || 1 || Telnet option: Byte Macro
 +
|-
 +
|| <DC3> || \x13 || 1 || ASCII control character: Device Control 3
 +
|-
 +
|| <14> || \x14 || 1 || Telnet option: Data Entry Terminal
 +
|-
 +
|| <DC4> || \x14 || 1 || ASCII control character: Device Control 4
 +
|-
 +
|| <15> || \x15 || 1 || Telnet option: SUPDUP
 +
|-
 +
|| <NAK> || \x15 || 1 || ASCII control character: Negative Acknowledge
 +
|-
 +
|| <16> || \x16 || 1 || Telnet option: SUPDUP Output
 +
|-
 +
|| <SYN> || \x16 || 1 || ASCII control character: Synchronous Idle
 +
|-
 +
|| <17> || \x17 || 1 || Telnet option: Send location
 +
|-
 +
|| <ETB> || \x17 || 1 || ASCII control character: End of Transmission Block
 +
|-
 +
|| <18> || \x18 || 1 ||
 +
|-
 +
|| <O_TERM> || \x18 || 1 || Telnet option: Terminal Type
 +
|-
 +
|| <CAN> || \x18 || 1 || ASCII control character: Cancel
 +
|-
 +
|| <19> || \x19 || 1 ||
 +
|-
 +
|| <O_EOR> || \x19 || 1 || Telnet option: End-of-Record
 +
|-
 +
|| <nowiki><EM></nowiki> || \x19 || 1 || ASCII control character: End of Medium
 +
|-
 +
|| <1A> || \x1a || 1 || Telnet option:  TACACS User Identification
 +
|-
 +
|| <nowiki><SUB></nowiki> || \x1a || 1 || ASCII control character: Substitute
 +
|-
 +
|| <1B> || \x1b || 1 || Telnet option: Output Marking
 +
|-
 +
|| <ESC> || \x1b || 1 || ASCII control character: Escape
 +
|-
 +
|| <1C> || \x1c || 1 || Telnet option: Terminal Location Number
 +
|-
 +
|| <FS> || \x1c || 1 || ASCII control character: File Separator
 +
|-
 +
|| <1D> || \x1d || 1 || Telnet option: Telnet 3270 Regime
 +
|-
 +
|| <GS> || \x1d || 1 || ASCII control character: Group Separator
 +
|-
 +
|| <1E> || \x1e || 1 || Telnet option: X.3 PAD
 +
|-
 +
|| <RS> || \x1e || 1 || ASCII control character: Record Separator
 +
|-
 +
|| <1F> || \x1f || 1 ||
 +
|-
 +
|| <O_NAWS> || \x1f || 1 || Telnet option: Negotiate About Window Size
 +
|-
 +
|| <US> || \x1f || 1 || ASCII control character: Unit Separator
 +
|-
 +
|| <SP> || \x20 || 1 || 32 dec. ASCII character: Space
 +
|-
 +
|| <O_NENV> || \x27 || 1 || 39 dec. Telnet option: New Environment (also MNES)
 +
|-
 +
|| <O_CHARS> || \x2a || 1 || 42 dec. Telnet option: Character Set
 +
|-
 +
|| <O_KERMIT> || \x2f || 1 || 47 dec. Telnet option: Kermit
 +
|-
 +
|| <O_MSDP> || \x45 || 1 || 69 dec. Telnet option: Mud Server Data Protocol
 +
|-
 +
|| <O_MSSP> || \x46 || 1 || 70 dec. Telnet option: Mud Server Status Protocol
 +
|-
 +
|| <O_MCCP> || \x55 || 1 || 85 dec
 +
|-
 +
|| <O_MCCP2> || \x56 || 1 || 86 dec
 +
|-
 +
|| <O_MSP> || \x5a || 1 || 90 dec. Telnet option: Mud Sound Protocol
 +
|-
 +
|| <O_MXP> || \x5b || 1 || 91 dec. Telnet option: Mud eXtension Protocol
 +
|-
 +
|| <O_ZENITH> || \x5d || 1 || 93 dec. Telnet option: Zenith Mud Protocol
 +
|-
 +
|| <O_AARDWULF> || \x66 || 1 || 102 dec. Telnet option: Aardwuld Data Protocol
 +
|-
 +
|| <nowiki><DEL></nowiki> || \x7f || 1 || 127 dec. ASCII control character: Delete
 +
|-
 +
|| <O_ATCP> || \xc8 || 1 || 200 dec
 +
|-
 +
|| <O_GMCP> || \xc9 || 1 || 201 dec
 +
|-
 +
|| <T_EOR> || \xef || 1 || 239 dec
 +
|-
 +
|| <F0> || \xf0 || 1 ||
 +
|-
 +
|| <T_SE> || \xf0 || 1 ||
 +
|-
 +
|| <F1> || \xf1 || 1 ||
 +
|-
 +
|| <T_NOP> || \xf1 || 1 ||
 +
|-
 +
|| <F2> || \xf2 || 1 ||
 +
|-
 +
|| <T_DM> || \xf2 || 1 ||
 +
|-
 +
|| <F3> || \xf3 || 1 ||
 +
|-
 +
|| <T_BRK> || \xf3 || 1 ||
 +
|-
 +
|| <F4> || \xf4 || 1 ||
 +
|-
 +
|| <T_IP> || \xf4 || 1 ||
 +
|-
 +
|| <F5> || \xf5 || 1 ||
 +
|-
 +
|| <T_ABOP> || \xf5 || 1 ||
 +
|-
 +
|| <F6> || \xf6 || 1 ||
 +
|-
 +
|| <T_AYT> || \xf6 || 1 ||
 +
|-
 +
|| <F7> || \xf7 || 1 ||
 +
|-
 +
|| <T_EC> || \xf7 || 1 ||
 +
|-
 +
|| <F8> || \xf8 || 1 ||
 +
|-
 +
|| <T_EL> || \xf8 || 1 ||
 +
|-
 +
|| <F9> || \xf9 || 1 ||
 +
|-
 +
|| <T_GA> || \xf9 || 1 ||
 +
|-
 +
|| <FA> || \xfa || 1 ||
 +
|-
 +
|| <T_SB> || \xfa || 1 ||
 +
|-
 +
|| <FB> || \xfb || 1 ||
 +
|-
 +
|| <T_WILL> || \xfb || 1 ||
 +
|-
 +
|| <FC> || \xfc || 1 ||
 +
|-
 +
|| <T_WONT> || \xfc || 1 ||
 +
|-
 +
|| <FD> || \xfd || 1 ||
 +
|-
 +
|| <T_DO> || \xfd || 1 ||
 +
|-
 +
|| <FE> || \xfe || 1 ||
 +
|-
 +
|| <T_DONT> || \xfe || 1 ||
 +
|-
 +
|| <FF> || \xff || 1 ||
 +
|-
 +
|| <T_IAC> || \xff'
 +
|}
  
cecho("myinfo", "<green>All of this text is green in the myinfo miniconsole.")
+
;Example
 +
<syntaxhighlight lang="lua">
 +
-- a comment explaining what is going on, if there is multiple functionalities (or optional parameters) the examples should start simple and progress in complexity if needed!
 +
-- the examples should be small, but self-contained so new users can copy & paste immediately without going diving in lots other function examples first.
 +
-- comments up top should introduce / explain what it does
  
cecho("<green>(╯°□°)<dark_green>╯︵ ┻━┻")
+
local something = feedTelnet(exampleValue)
 +
if something then
 +
  -- do something with something (assuming there is a meaningful return value)
 +
end
  
cecho("°º¤ø,¸¸,ø¤º°`°º¤ø,¸,ø¤°º¤ø,¸¸,ø¤º°`°º¤ø,¸")
+
-- maybe another example for the optional second case
 +
local somethingElse = function(exampleValue, anotherValue)
  
cecho([[
+
-- lastly, include an example with error handling to give an idea of good practice
██╗    ██╗    ██╗███╗  ██╗███████╗    █████╗ ██████╗ ████████╗
+
local ok, err = function()
███║    ██║    ██║████╗  ██║██╔════╝    ██╔══██╗██╔══██╗╚══██╔══╝
+
if not ok then
╚██║    ██║    ██║██╔██╗ ██║█████╗      ███████║██████╔╝   ██║
+
   debugc(f"Error: unable to do <particular thing> because {err}\n")
██║    ██║    ██║██║╚██╗██║██╔══╝      ██╔══██║██╔══██╗   ██║
+
   return
██║    ███████╗██║██║ ╚████║███████╗    ██║  ██║██║  ██║  ██║
+
end
╚═╝    ╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝    ╚═╝  ╚═╝╚═╝  ╚═╝  ╚═╝
 
]])
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==cecho2ansi PR# 5672 merged==
+
; Additional development notes
 +
-- This function is still being written up.
  
;ansiFormattedString = cecho2ansi(text)
+
=String Functions=
 +
:These functions are used to manipulate strings.
  
:Converts cecho formatted text to ansi formatted text. Used by cfeedTriggers, but useful if you want ansi formatted text for any other reason.
+
=Table Functions=
 +
:These functions are used to manipulate tables. Through them you can add to tables, remove values, check if a value is present in the table, check the size of a table, and more.
  
;See also:[[Manual:Lua_Functions#cecho|cecho()]], [[Manual:Lua_Functions#cfeedTriggers|cfeedTriggers()]]
+
=Text to Speech Functions=
 +
:These functions are used to create sound from written words. Check out our [[Special:MyLanguage/Manual:Text-to-Speech|Text-To-Speech Manual]] for more detail on how this all works together.
  
{{MudletVersion|4.15}}
+
=UI Functions=
 +
:These functions are used to construct custom user GUIs. They deal mainly with miniconsole/label/gauge creation and manipulation as well as displaying or formatting information on the screen.
 +
 
 +
==cecho2decho PR#6849 merged==
 +
; convertedString = cecho2decho(str)
 +
 
 +
:Converts a cecho formatted string to a decho formatted one.
 +
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
  
{{note}} This function uses the ansi short colors (0-15) for color names which have base 16 ansi equivalents, such as 'red', 'blue', "lightBlue", "cyan", etc rather than the values defined in the color_table. If there is no base ansi equivalent then it will use the rgb values from the color_table for the color.
+
{{MudletVersion|4.18}}
  
 
;Parameters
 
;Parameters
*''text:''
+
* ''str''
:The cecho formatted text for conversion
+
: string you wish to convert from cecho to decho
 
+
;Returns  
;Returns
+
* a string formatted for decho
*String converted to ansi formatting
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- replicates the functionality of cfeedTriggers() for a single line.
+
-- convert to a decho string and use decho to display it
-- you would most likely just use cfeedTriggers, but it makes for a tidy example.
+
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
feedTriggers(cecho2ansi("\n<red>This is red.<reset> <i>italic</i>, <b>bold</b>, <s>strikethrough</s>, <u>underline</u>\n"))
+
decho(cecho2decho(cechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
;Additional development notes
+
==cecho2hecho PR#6849 merged==
 +
; convertedString = cecho2hecho(str)
  
==createScrollBox PR #5739==
+
:Converts a cecho formatted string to an hecho formatted one.
;createScrollBox([name of parent window], name, x, y, width, height)
+
;See also: [[Manual:Lua_Functions#hecho2cecho|hecho2cecho()]], [[Manual:Lua_Functions#cecho2html|cecho2html()]]
  
: creates a graphical elements able to hold other graphical elements such as labels, miniconsoles, command lines etc. in it.
+
{{MudletVersion|4.18}}
If the added elements don't fit into the ScrollBox scrollbars appear and allow scrolling.
 
: Returns true or false.
 
 
 
: See also: [[Manual:Lua_Functions#createLabel|createLabel()]], [[Manual:Lua_Functions#hideWindow|hideWindow()]], [[Manual:Lua_Functions#showWindow|showWindow()]], [[Manual:Lua_Functions#resizeWindow|resizeWindow()]], [[Manual:Lua_Functions#moveWindow|moveWindow()]], [[Manual:Lua_Functions#setWindow|setWindow()]]
 
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
* ''name of parent window:''  
+
* ''str''
: (Optional) name of the parent window the scrollBox is created in. Defaults to the main window if not provided.
+
: string you wish to convert from cecho to decho
* ''name:''
+
;Returns
: The name of the scrollBox. Must be unique. Passed as a string.
+
* a string formatted for hecho
* ''x'', ''y'', ''width'', ''height''
 
: Parameters to set set the window size and location
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a ScrollBox with the name sBox
+
-- convert to an hecho string and use hecho to display it
createScrollBox("SBox",0,0,300,200)
+
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
 
+
hecho(cecho2hecho(cechoString))
-- create 3 Labels and put them into the ScrollBox
 
createLabel("SBox","SBoxLabel",0,0,200,200,1)
 
createLabel("SBox","SBoxLabel2",200,0,200,200,1)
 
createLabel("SBox","SBoxLabel3",400,0,200,200,1)
 
 
 
-- put some text on the labels
 
echo("SBoxLabel","Label")
 
echo("SBoxLabel2","Label2")
 
echo("SBoxLabel3","Label3")
 
 
 
-- change the colours of the labels to make it easier to distinguish them
 
setBackgroundColor("SBoxLabel",255,0,0)
 
setBackgroundColor("SBoxLabel2",0,255,0)
 
setBackgroundColor("SBoxLabel3",0,0,255)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==decho PR #5669 merged PR5719 merged PR5751 merged ==
+
==cecho2html PR#6849 merged==
;decho ([name of console,] text)
+
; convertedString = cecho2html(str[, resetFormat])
:Color changes can be made using the format <FR,FG,FB:BR,BG,BB,[BA]> where each field is a number from 0 to 255. The background portion can be omitted using <FR,FG,FB> or the foreground portion can be omitted using <:BR,BG,BB,[BA]>. Arguments 2 and 3 set the default fore and background colors for the string using the same format as is used within the string, sans angle brackets, e.g. ''decho("<50,50,0:0,255,0>test")''.
 
:You can also include <code><nowiki><i>italics</i></nowiki></code>, <code><nowiki><b>bold</b></nowiki></code>, <code><nowiki><s>strikethrough</s></nowiki></code>, <code><nowiki><o>overline</o></nowiki></code>, and <code><nowiki><u>underline</u></nowiki></code> tags.
 
  
{{Note}} Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you decho it will erase any previous echo sent to the label.
+
:Converts a cecho formatted string to an html formatted one.  
 +
;See also: [[Manual:Lua_Functions#decho2cecho|decho2cecho()]], [[Manual:Lua_Functions#decho2html|cecho2html()]]
  
:See also: [[#cecho|cecho()]], [[#hecho|hecho()]], [[#copy2decho|copy2decho()]]
+
{{MudletVersion|4.18}}
  
 
;Parameters
 
;Parameters
*''name of console''
+
* ''str''
:(Optional) Name of the console to echo to. If no name is given, this will defaults to the main window.
+
: string you wish to convert from cecho to decho
*''text:''
+
* ''resetFormat''
:The text that you’d like to echo with embedded color tags. Tags take the RGB values only, see below for an explanation.
+
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 
+
;Returns
 
+
* a string formatted for html
{{note}}
 
Optional background transparancy parameter (BA) available in Mudlet 4.10+
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
decho("<50,50,0:0,255,0>test")
+
-- create the base string
 +
local cechoString = "<red><b>!!ALERT!!:</b><orange> Something has gone wrong!\n"
  
decho("miniconsolename", "<50,50,0:0,255,0>test")
+
-- create a label to display the result onto
 +
testLabel = Geyser.Label:new({name = "testLabel"})
  
decho("\n<255,0,0>Red text with <i>italics</i>, <u>underline</u>, <s>strikethrough</s>, and <b>bold</b> formatting.")
+
-- convert the cecho string to an html one, using the default formatting of testLabel created above
 +
local htmlString = cecho2html(cechoString, testLabel:getFormat())
  
decho("<\n<0,128,0><o><u>Green text with both over and underlines.</u></o>")
+
-- and finally echo it to the label to see
 +
-- I use rawEcho as that displays the html exactly as given.
 +
testLabel:rawEcho(htmlString)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==decho2ansi PR# 5671 merged==
+
==decho2cecho PR#6849 merged==
 +
; convertedString = decho2cecho(str)
  
;ansiFormattedString = decho2ansi(text)
+
:Converts a decho formatted string to a cecho formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
  
:Converts decho formatted text to ansi formatted text. Used by dfeedTriggers, but useful if you want ansi formatted text for any other reason.
+
{{MudletVersion|4.18}}
  
;See also:[[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#dfeedTriggers|dfeedTriggers()]]
+
;Parameters
 
+
* ''str''
{{MudletVersion|4.10+}}
+
: string you wish to convert from decho to cecho
 
+
;Returns  
{{Note}} non-color formatting added in Mudlet 4.15+
+
* a string formatted for cecho
 
 
; Parameters
 
*''text:''
 
:The decho formatted text for conversion
 
 
 
;Returns
 
* String converted to ansi formatting
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- replicates the functionality of dfeedTriggers() for a single line.
+
-- convert to a decho string and use cecho to display it
-- you would most likely just use dfeedTriggers, but it makes for a tidy example.
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
feedTriggers(decho2ansi("\n<128,0,0>This is red.<r> <i>italic</i>, <b>bold</b>, <s>strikethrough</s>, <u>underline</u>\n"))
+
cecho(decho2cecho(dechoString))
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getHTMLformat PR#5751 merged==
+
==decho2hecho PR#6849 merged==
 +
; convertedString = decho2hecho(str)
  
;spanTag = getHTMLformat(formatTable)
+
:Converts a decho formatted string to an hecho formatted one.
 +
;See also: [[Manual:Lua_Functions#hecho2decho|hecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
  
:Takes in a table of formatting options in the same style as [[Manual:Lua_Functions#getTextFormat|getTextFormat()]] and returns a span tag which will format text after it as the table describes.
+
{{MudletVersion|4.18}}
 
 
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
*''formatTable:''
+
* ''str''
:Table with formatting options configured. Keys are foreground, background, bold, underline, overline, strikeout, italic, and reverse. All except for foreground and background should be boolean (true/false) values. Foreground and background are either { r, g, b, a } tables, or strings with QSS formatting directives
+
: string you wish to convert from decho to decho
 
+
;Returns  
;Returns
+
* a string formatted for hecho
*A string with the html span tag to format text in accordance with the format table.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- Returns a span tag for bold, red text on a green background
+
-- convert to an hecho string and use hecho to display it
local span = getHTMLformat({
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
  foreground = { 255, 0, 0 },
+
hecho(decho2hecho(dechoString))
  background = "#00FF00",
 
  bold = true
 
})
 
 
 
-- span will be '<span style="color: rgb(255, 0, 0);background-color: #00FF00; font-weight: bold; font-style: normal; text-decoration: none;">'
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==getLabelFormat PR#5751 merged==
+
==decho2html PR#6849 merged==
 
+
; convertedString = decho2html(str[, resetFormat])
;formatTable = getLabelFormat(labelName)
 
 
 
: Returns a format table like the one returned by getTextFormat and suitable for getHTMLspan which will format text the same way as simply doing an echo to the label would
 
  
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getHTMLspan|getHTMLspan()]]
+
:Converts a decho formatted string to an html formatted one.
 +
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#decho2html|decho2html()]]
  
{{MudletVersion|4.15}}
+
{{MudletVersion|4.18}}
  
 
;Parameters
 
;Parameters
*''labelName:''
+
* ''str''
: The name of the label to scan the format of
+
: string you wish to convert from decho to decho
 
+
* ''resetFormat''
;Returns
+
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
*A table with all the formatting options to achieve a default text format for label labelName.
+
;Returns  
 +
* a string formatted for html
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- creates a test label, sets a stylesheet, and then returns the default format table for that label.
+
-- create the base string
createLabel("testLabel", 10, 10, 300, 200, 1)
+
local dechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n"
setLabelStyleSheet([[
+
 
  color: rgb(0,0,180);
+
-- create a label to display the result onto
  border-width: 1px;
+
testLabel = Geyser.Label:new({name = "testLabel"})
  border-style: solid;
 
  border-color: gold;
 
  border-radius: 10px;
 
  font-size: 12.0pt;
 
  background: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);
 
]])
 
local fmt = getLabelFormat("testLabel"))
 
  
--[[
+
-- convert the decho string to an html one, using the default formatting of testLabel created above
{
+
local htmlString = decho2html(dechoString, testLabel:getFormat())
  background = "rgba(0, 0, 0, 0)", -- this is transparent
 
  bold = false,
 
  foreground = "rgb(0,0,180)",
 
  italic = false,
 
  overline = false,
 
  reverse = false,
 
  strikeout = false,
 
  underline = false
 
}
 
--]]
 
  
 +
-- and finally echo it to the label to see
 +
-- I use rawEcho as that displays the html exactly as given.
 +
testLabel:rawEcho(htmlString)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
==deleteMultiline PR #6779 merged==
  
==getLabelSizeHint PR#5815 merged==
+
; ok,err = deleteMultiline([triggerDelta])
  
;width, height = getLabelSizeHint(labelName)
+
:Deletes all lines between when the multiline trigger fires and when the first trigger matched. Put another way, it deletes everything since the pattern in slot 1 matched.
 +
;See also: [[Manual:Lua_Functions#deleteLine|deleteLine()]], [[Manual:Lua_Functions#replaceLine|replaceLine()]]
  
: Returns the suggested labelsize as width and height
+
{{MudletVersion|4.18}}
  
;See also:[[Manual:Lua_Functions#getTextFormat|getTextFormat()]], [[Manual:Lua_Functions#getHTMLspan|getHTMLspan()]]
+
{{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.
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
*''labelName:''
+
* ''[optional]triggerDelta:''
: The name of the label to get the suggested size from
+
: The line delta from the multiline trigger it is being called from. It is best to pass this in to ensure all lines are caught. If not given it will try to guess based on the number of patterns how many lines at most it might have to delete.
  
;Returns
+
;Returns  
*suggested width and height (to fit text and/or an image on a label)
+
* true if the function was able to run successfully, nil+error if something went wrong.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- text resizing example
+
-- if this trigger has a line delta of 3, you would call
-- create the label
+
deleteMultiline(3)
createLabel("textLabel",400,400,300,300,1)
 
-- put some text on it
 
echo("textLabel", "This is my Test.\nAnother Test")
 
-- resizes the label to fit the text
 
resizeWindow("textLabel", getLabelSizeHint("textLabel"))
 
 
 
-- image resizing example
 
-- create the label
 
createLabel("imageLabel",400,400,300,300,1)
 
-- put some image on it
 
setBackgroundImage("imageLabel", getMudletHomeDir.."/myLabelImage.png")
 
-- resizes the label to fit the image
 
resizeWindow("imageLabel", getLabelSizeHint("imageLabel"))
 
  
 +
-- same thing, but with error handling
 +
local ok,err = deleteMultiline(3)
 +
if not ok then
 +
  cecho("\n<firebrick>I could not delete the lines because: " .. err)
 +
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==hecho PR #5669 merged, PR5719 merged, PR5751 merged==
+
; Additional development notes
;hecho([windowName], text)
 
:Echoes text that can be easily formatted with colour tags in the hexadecimal format. You can also use italics, bold, strikethrough, and underline tags.
 
:See Also: [[Manual:Lua_Functions#decho|decho()]], [[Manual:Lua_Functions#cecho|cecho()]]
 
  
{{Note}} Support for labels added in Mudlet 4.15; however, it does not turn a label into a miniconsole and every time you hecho it will erase any previous echo sent to the label.
+
==echoPopup, revised in PR #6946==
 +
;echoPopup([windowName,] text, {commands}, {hints}[, useCurrentFormatElseDefault])
 +
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if there is one extra hint then the first one will be used as a (maybe containing Qt rich-text markup) tool-tip for the text otherwise the remaining hints will be concatenated, one-per-line, as a tool-tip when the text is hovered over by the pointer.
  
;Parameters
+
; Parameters
*''windowName:''
+
* ''windowName:''
:(optional) name of the window to echo to. Can either be omitted or "main" for the main window, else specify the miniconsoles name.
+
: (optional) name of the window as a string to echo to. Use either ''main'' or omit for the main window, or the miniconsole's or user-window's name otherwise.
*''text:''
+
* ''text:''
:The text to display, with color changes made within the string using the format |cFRFGFB,BRBGBB or #FRFGFB,BRBGBB where FR is the foreground red value, FG is the foreground green value, FB is the foreground blue value, BR is the background red value, etc., BRBGBB is optional. |r or #r can be used within the string to reset the colors to default. Hexadecimal color codes can be found here: https://www.color-hex.com/
+
: the text string to display.
 
+
* ''{commands}:''
{{note}}
+
: 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>.
Transparency for background in hex-format available in Mudlet 4.10+
+
* ''{hints}:''
 +
: a table of strings which will be shown on the right-click menu and as a tool-tip for the ''text''. If the number is the same as that of the ''commands'' table then they all will be used for the right-click menu and listed (one per line) as a plain text tooltip; alternatively if there is one extra in number than the ''commands'' table the first will be used purely for the tool tip and the remainder will be used for the right-click menu. This additional entry may be formatted as Qt style "rich-text" (in the same manner as labels elsewhere in the GUI).
 +
::* If a particular position in the ''commands'' table is an empty string ''""'' but there is something in the ''hints'' table then it will be listed in the right-click menu but as it does not do anything it will be shown ''greyed-out'' i.e. disabled and will not be clickable.
 +
::* If a particular position in '''both''' the ''commands'' and the ''hints'' table are empty strings ''""'' then this item will show as a ''separator'' (usually as a horizontal-line) in the right-click menu and it will not be clickable/do anything.  
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if ''true'' or the link default (blue underline) if ''false'', if omitted the default format is used.
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
hecho("\n#ffffff White text!")
+
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
-- your text in white
+
echoPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
hecho("\n#ca0004 Red text! And now reset #rit to the default color")
 
-- your text in red, then reset to default using #r
 
hecho("\n#ffffff,ca0004 White text with a red background!")
 
-- your text in white, against a red background
 
hecho("\n|c0000ff Blue text, this time using |c instead of #")
 
-- your text in blue, activated with |c vs #.
 
hecho("\n#ff0000Red text with #iitalics#/i, |uunderline|/u, #ooverline#/o, #sstrikethrough#/s, and #bbold#/b formatting.")
 
-- shows the various individual formatting options
 
hecho("\n#008000#o#uGreen text with both over and underlines.#/o#/u")
 
</syntaxhighlight>
 
  
==hecho2ansi PR# 5671 merged==
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
 +
echoPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
  
;ansiFormattedString = hecho2ansi(text)
+
-- one can also provide helpful information
  
:Converts hecho formatted text to ansi formatted text. Used by hfeedTriggers, but useful if you want ansi formatted text for any other reason.
+
-- todo: an example with rich-text in the tool-tips(s) - not complete yet!
 +
echoPopup("Fancy popup", {[[echo("Doing command 1 (default one)")]], "", "", [[echo("Doing command 3")]], [[echo("Doing another command (number 4)"]], [[echo("Doing another command (number 5)"]])}, {"<p>This tooltip has HTML type tags in/around it, and it will get word-wrapped automatically to fit into a reasonable rectangle.</p><p><b>Plus</b> it can have those HTML like <i>effects</i> and be easily formatted into more than one paragraph and with <span style=\"color:cyan\">bits</span> in <span style=\"color:lime\">different</span> colors!</p><p>This example also demonstrates how to produce disabled menu (right-click) items, how to insert separators and how it now will handle multiple items with the same hint (prior to PR 6945 such duplicates will all run the command associated with the last one!) If the first command/function is an empty string then clicking on the text will have no effect, but hovering the mouse over the text will still produce the tooltip, this could be useful to display extra information about the text without doing anything by default.</p>", "Command 1 (default)", "", "Command 2 (disabled)", "Command 3", "Another command", "Another command"}, true)
 +
echo(" remaining text.\n")
  
;See also:[[Manual:Lua_Functions#hecho|hecho()]], [[Manual:Lua_Functions#hfeedTriggers|hfeedTriggers()]]
 
 
{{MudletVersion|4.10+}}
 
 
{{Note}} non-color formatting added in Mudlet 4.15+
 
 
;Parameters
 
*''text:''
 
:The hecho formatted text for conversion
 
 
;Returns
 
*String converted to ansi formatting
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- replicates the functionality of hfeedTriggers() for a single line.
 
-- you would most likely just use hfeedTriggers, but it makes for a tidy example.
 
feedTriggers(hecho2ansi("\n#800000This is red.#r #iitalic#/i, #bbold#/b, #sstrikethrough#/s, #uunderline#/u\n"))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMovie PR #5827==
+
==hecho2cecho PR#6849 merged==
;setMovie(label name, path to gif)
+
; convertedString = hecho2cecho(str)
  
: Adds a gif to the selected label and animates it. Note that gifs are pretty expensive to play, so don't add too many at once.
+
:Converts a hecho formatted string to a cecho formatted one.  
: Some websites you can get gifs from are [https://tenor.com/search/stickers-gifs Tenor] and [https://giphy.com/stickers Giphy] (not officially endorsed).
+
;See also: [[Manual:Lua_Functions#cecho2decho|cecho2decho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
: Returns true
+
{{MudletVersion|4.18}}
 
 
: See also: [[Manual:Lua_Functions#setMovieStart|setMovieStart()]], [[Manual:Lua_Functions#setMoviePaused|setMoviePaused()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
 
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
* ''label name:''  
+
* ''str''
: name of the label the gif will be animated on
+
: string you wish to convert from hecho to cecho
* ''path:''
+
;Returns
: path of the gif file
+
* a string formatted for cecho
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- download & show a gif within mudlet
+
-- convert to a hecho string and use cecho to display it
local saveto = getMudletHomeDir().."/kymip.gif"
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
-- animation credit to https://opengameart.org/content/kymiball-ii-third-prototype-scraps
+
cecho(hecho2cecho(hechoString))
local url = "https://opengameart.org/sites/default/files/kymip_0.gif"
 
 
 
if downloadHandler then killAnonymousEventHandler(downloadHandler) end
 
downloadHandler = registerAnonymousEventHandler("sysDownloadDone",
 
  function(_, filename)
 
    if filename ~= saveto then
 
      return true
 
    end
 
   
 
    local width, height = getImageSize(saveto)
 
 
 
    createLabel("kymip", 300, 300, width, height, 0)
 
    setMovie("kymip", saveto)
 
    setLabelReleaseCallback("kymip", function() deleteLabel("kymip") end)
 
  end, true)
 
 
 
downloadFile(saveto, url)
 
</syntaxhighlight>
 
 
 
<syntaxhighlight lang="lua">
 
local gifpath = getMudletHomeDir().."/movie.gif"
 
 
 
local width, height = getImageSize(gifpath)
 
 
 
-- create a label with the name mygif
 
createLabel("mygif", 0, 0, width, height,0)
 
-- put the gif on the label and animate it
 
setMovie("mygif", gifpath)
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMovieStart PR #5827==
+
==hecho2decho PR#6849 merged==
;setMovieStart(label name)
+
; convertedString = hecho2decho(str)
  
: Starts the gif animation - if it was previously stopped or paused.
+
:Converts a hecho formatted string to a decho formatted one.  
: Returns true
+
;See also: [[Manual:Lua_Functions#decho2hecho|decho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#setMoviePaused|setMoviePaused()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
+
{{MudletVersion|4.18}}
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
* ''label name:''  
+
* ''str''
: name of the gif label
+
: string you wish to convert from hecho to decho
 +
;Returns
 +
* a string formatted for decho
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a label with the name myMovie
+
-- convert to a decho string and use decho to display it
createLabel("myMovie",0,0,200,200,0)
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
 
+
decho(hecho2decho(hechoString))
-- puts the gif on the label and animates it
 
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
 
--stops the animation
 
setMoviePaused("myMovie")
 
--restart the animation
 
setMovieStart("myMovie")
 
 
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMoviePaused PR #5827==
+
==hecho2html PR#6849 merged==
;setMoviePaused(label name)
+
; convertedString = hecho2html(str[, resetFormat])
  
: Toggles pause/unpause of the gif animation on the label
+
:Converts a hecho formatted string to an html formatted one.
: Returns true
+
;See also: [[Manual:Lua_Functions#cecho2hecho|cecho2hecho()]], [[Manual:Lua_Functions#hecho2html|hecho2html()]]
  
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#setMovieStart|setMovieStart()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
+
{{MudletVersion|4.18}}
 
 
{{MudletVersion|4.15}}
 
  
 
;Parameters
 
;Parameters
* ''label name:''  
+
* ''str''
: name of the gif label
+
: string you wish to convert from hecho to hecho
 +
* ''resetFormat''
 +
: optional table of default formatting options. As returned by [[Manual:Lua_Functions#getLabelFormat|getLabelFormat()]]
 +
;Returns
 +
* a string formatted for html
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a label with the name myMovie
+
-- create the base string
createLabel("myMovie",0,0,200,200,0)
+
local hechoString = "#ff0000#b!!ALERT!!:#/b#ffa500 Something has gone wrong!\n""
  
-- puts the gif on the label and animates it
+
-- create a label to display the result onto
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
+
testLabel = Geyser.Label:new({name = "testLabel"})
--stops the animation
 
setMoviePaused("myMovie")
 
  
 +
-- convert the hecho string to an html one, using the default formatting of testLabel created above
 +
local htmlString = hecho2html(hechoString, testLabel:getFormat())
 +
 +
-- and finally echo it to the label to see
 +
-- I use rawEcho as that displays the html exactly as given.
 +
testLabel:rawEcho(htmlString)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==setMovieFrame PR #5827==
+
==insertPopup, revised in PR #6925==
;setMovieFrame(label name, frame nr)
+
;insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])
 +
: Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if a tool-tips table is not provided the same hints will also be listed one-per-line as a tool-tip but if a matching number of tool-tips are provided they will be concatenated to provide a tool-tip when the text is hovered over by the pointer - these tool-tips can be ''rich-text'' to produce information formatted with additional content in the same manner as labels.
  
: Jump to a specific frame in the gif.
+
; Parameters
: Returns true if successful, and false if frame doesn't exist.
+
* ''windowName:''
 
+
: (optional) name of the window as a string to echo to. Use either ''main'' or omit for the main window, or the miniconsole's or user-window's name otherwise.
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#setMovieStart|setMovieStart()]], [[Manual:Lua_Functions#setMoviePaused|setMoviePaused()]], [[Manual:Lua_Functions#setMovieSpeed|setMovieSpeed()]]
+
* ''text:''
 
+
: the text string to display.
{{MudletVersion|4.15}}
+
* ''{commands}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>.
 +
* ''{hints}:''
 +
: a table of strings which will be shown on the right-click menu (and popup if no {tool-tips} table is provided). If a particular position in both the commands and hints table are both the empty string ''""'' but there is something in the tool-tips table, no entry for that position will be made in the context menu but the tool-tip can still display something which can include images or text.
 +
* ''{tool-tips}:''
 +
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided.
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if ''true'' or the link default (blue underline) if ''false'', if omitted the default format is used.
  
;Parameters
+
{{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.
* ''label name:''
 
: name of the gif label
 
* ''frame nr:''
 
: the gif animations frame nr to jump to
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- create a label with the name myMovie
+
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
createLabel("myMovie",0,0,200,200,0)
+
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
  
-- puts the gif on the label and animates it
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
+
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
--stops the animation
 
setMoviePaused("myMovie")
 
-- jumps to frame 12 of the animation
 
setMovieFrame("myMovie", 12)
 
--start the animation
 
setMovieStart("myMovie")
 
  
</syntaxhighlight>
+
-- one can also provide helpful information
  
==setMovieSpeed PR #5827==
+
-- todo: an example with rich-text in the tool-tips(s)
;setMovieSpeed(label name, speed in percent)
 
  
: Set the animation speed, in percent
+
</syntaxhighlight>
: Returns true
 
  
: See also: [[Manual:Lua_Functions#setMovie|setMovie()]], [[Manual:Lua_Functions#setMovieStart|setMovieStart()]], [[Manual:Lua_Functions#setMoviePaused|setMoviePaused()]], [[Manual:Lua_Functions#setMovieFrame|setMovieFrame()]]
+
=Discord Functions=
 +
:All functions to customize the information Mudlet displays in Discord's rich presence interface. For an overview on how all of these functions tie in together, see our [[Special:MyLanguage/Manual:Scripting#Discord_Rich_Presence|Discord scripting overview]].
  
{{MudletVersion|4.15}}
+
=Mud Client Media Protocol=
 +
:All GMCP functions to send sound and music events. For an overview on how all of these functions tie in together, see our [[Special:MyLanguage/Manual:Scripting#MUD_Client_Media_Protocol|MUD Client Media Protocol scripting overview]].
  
;Parameters
+
=Supported Protocols=
* ''label name:''
 
: name of the gif label
 
* ''speed in percent:''
 
: the gif animations speed in percent for example 50 for 50% speed
 
  
;Example
+
=Events=
<syntaxhighlight lang="lua">
+
: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.
-- create a label with the name myMovie
 
createLabel("myMovie",0,0,200,200,0)
 
  
-- puts the gif on the label and animates it
+
===sysSettingChanged, PR #7476===
setMovie("myMovie", getMudletHomeDir().."/movie.gif")
+
This event is raised when a Preferences or Mudlet setting has changed. The first argument contains the setting that was changed, further arguments detail the change.
--accelerates the animation to a speed of 150%
 
setMovieSpeed("myMovie",150)
 
  
 +
Currently implemented sysSettingChanged events are;
  
</syntaxhighlight>
+
* "main window font" - raised when the main window/console font has changed via API or Preferences window. Returns two additional arguments, the font family and the font size. e.g. {"main window font", "Times New Roman", 12 }
  
==windowType PR# 5696 open==
+
{{MudletVersion| ?.??}}
;typeOfWindow = windowType(windowName)
 
  
:Given the name of a window, will return if it's a label, miniconsole, userwindow or a commandline.
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/7476
  
;See also:[[Manual:Lua_Functions#createLabel|createLabel()]], [[Manual:Lua_Functions#openUserWindow|openUserWindow()]]
+
===sysMapAreaChanged, PR #6615===
 +
Raised when the area being viewed in the mapper is changed, either by the player-room being set to a new area or the user selecting a different area in the area selection combo-box in the mapper controls area. Returns two additional arguments being the areaID of the area being switched to and then the one for the area that is being left.
  
{{MudletVersion|4.15}}
+
{{MudletVersion| ?.??}}
  
;Parameters
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615
*''windowName:''
 
:The name used to create the window element. Use "main" for the main console
 
  
 +
===sysMapWindowMousePressEvent, PR #6962===
 +
Raised when the mouse is left-clicked on the mapper window.
  
;Returns
+
{{MudletVersion| ?.??}}
*Window type as string ("label", "miniconsole", "userwindow", or "commandline") or nil+error if it does not exist.
 
  
;Example
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962
<syntaxhighlight lang="lua">
 
-- Create a Geyser label and and check its type
 
testLabel = Geyser.Label:new({name = "testLabel"})
 
display(windowType(testLabel.name))  -- displays "label"
 
  
-- the main console returns "miniconsole" because it uses the same formatting functions
+
===sysWindowOverflowEvent, PR #6872===
display(windowType("main")) -- displays "miniconsole"
+
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.
  
-- check for the existence of a window
+
{{MudletVersion| ?.??}}
local windowName = "this thing does not exist"
 
local ok, err = windowType(windowName)
 
if ok then
 
  -- do things with it, as it does exist.
 
  -- the ok variable will hold the type of window it is ("label", "commandline", etc)
 
else
 
  cecho("<red>ALERT!! window does not exist")
 
end
 
</syntaxhighlight>
 
 
 
;Additional development notes
 
  
=Discord Functions=
+
{{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).
: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]].
 

Latest revision as of 14:58, 3 November 2024

This page is for the development of documentation for Lua API functions that are currently being worked on. Ideally the entries here can be created in the same format as will be eventually used in Lua Functions and its sub-sites.

Please use the Area_51/Template to add new entries in the sections below.

Links to other functions or parts in other sections (i.e. the main Wiki area) need to include the section details before the '#' character in the link identifier on the left side of the '|' divider between the identifier and the display text. e.g.

[[Manual:Mapper_Functions#getCustomLines|getCustomLines()]]

rather than:

[[#getCustomLines|getCustomLines()]]

which would refer to a link within the current (in this case Area 51) section. Note that this ought to be removed once the article is moved to the main wiki area!

The following headings reflect those present in the main Wiki area of the Lua API functions. It is suggested that new entries are added so as to maintain a sorted alphabetical order under the appropriate heading.


Basic Essential Functions

These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.

Database Functions

A collection of functions for helping deal with the database.

Date/Time Functions

A collection of functions for handling date & time.

File System Functions

A collection of functions for interacting with the file system.

Mapper Functions

A collection of functions that manipulate the mapper and its related features.

addRoom PR #7184 merged

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

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

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

getAreaRooms1, PR #7520 open

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

See also: getAreaRooms()

setRoomArea PR #7184 merged==

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

updateMap

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


mapSymbolFontInfo, PR #4038 closed

mapSymbolFontInfo()
See also: setupMapSymbolFont()

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

returns
  • either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:
  • fontName - a string of the family name of the font specified
  • onlyUseThisFont - a boolean indicating whether glyphs from just the fontName font are to be used or if there is not a glyph for the required grapheme (character) then a glyph from the most suitable different font will be substituted instead. Should this be true and the specified font does not have the required glyph then the replacement character (typically something like ) could be used instead. Note that this may not affect the use of Color Emoji glyphs that are automatically used in some OSes but that behavior does vary across the range of operating systems that Mudlet can be run on.
  • scalingFactor - a floating point number between 0.50 and 2.00 which modifies the size of the symbols somewhat though the extremes are likely to be unsatisfactory because some of the particular symbols may be too small (and be less visible at smaller zoom levels) or too large (and be clipped by the edges of the room rectangle or circle).
  • or nil and an error message on failure.
As the symbol font details are stored in the (binary) map file rather than the profile then this function will not work until a map is loaded (or initialized, by activating a map window).

moveMapLabel, PR #6014 open

moveMapLabel(areaID/Name, labeID/Text, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])

Re-positions a map label within an area in the 2D mapper, in a similar manner as the moveRoom() function does for rooms and their custom exit lines. When moving a label to given coordinates this is the position that the top-left corner of the label will be positioned at; since the space allocated to a particular room on the map is ± 0.5 around the integer value of its x and y coordinates this means for a label which has a size of 1.0 x 1,0 (w x h) to position it centrally in the space for a single room at the coordinates (x, y, z) it should be positioned at (x - 0.5, y + 0.5, z).

See also: getMapLabels(), getMapLabel().
Mudlet VersionAvailable in Mudlet ?.??+

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

Parameters
  • areaID/Name:
Area ID as number or AreaName as string containing the map label.
  • labelID/Text:
Label ID as number (which will be 0 or greater) or the LabelText on a text label. All labels will have a unique ID number but there may be more than one text labels with a non-empty text string; only the first matching one will be moved by this function and image labels also have no text and will match the empty string. with mo or AreaName as string containing the map label.
  • coordX/deltaX:
A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the X-axis.
  • coordY/deltaY:
A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Y-axis.
  • coordZ/deltaZ:
(Optional) A floating point number for the absolute coordinate to use or the relative amount to move the label in "room coordinates" along the Z-axis, if omitted the label is not moved in the z-axis at all.
  • absoluteNotRelativeMove:
(Optional) a boolean value (defaults to false if omitted) as to whether to move the label to the absolute coordinates (true) or to move it the relative amount from its current location (false).
Returns
true on success or nil and an error message on failure, if successful it will also refresh the map display to show the result.
Example
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
moveMapLabel(0, 2, 3.0, 4.0)

-- move the first label in the area with the ID number of 2, one space to the west, note the final boolean argument is unneeded
moveMapLabel(0, 2, -1.0, 0.0, false)

-- move the second label in the area with the ID number of 2, three and a half spaces to the west, and two south **of the center of the current level it is on in the map**:
moveRoom(1, 2, -3.5, -2.0, true)

-- move the second label in the area with the ID number of 2, up three levels
moveRoom(1, 2, 0.0, 0.0, 3.0)

-- move the second label in the "Test 1" area one space to the west, note the last two arguments are unneeded
moveRoom("Test 1", 1, -1.0, 0.0, 0.0, false)

-- move the (top-left corner of the first) label with the text "Home" in the area with ID number 5 to the **center of the whole map**, note the last two arguments are required in this case:
moveRoom(5, "Home", 0.0, 0.0, 0.0, true)

-- all of the above will return the 'true'  boolean value assuming there are the indicated labels and areas

moveRoom, PR #6010 open

moveRoom(roomID, coordX/deltaX, coordY/deltaY[, coordZ/deltaZ][, absoluteNotRelativeMove])

Re-positions a room within an area, in the same manner as the "move to" context menu item for one or more rooms in the 2D mapper. Like that method this will also shift the entirety of any custom exit lines defined for the room concerned. This contrasts with the behavior of the setRoomCoordinates() which only moves the starting point of such custom exit lines so that they still emerge from the room to which they belong but otherwise remain pointing to the original place.

See also: setRoomCoordinates()
Mudlet VersionAvailable in Mudlet ?.??+

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

Parameters
  • roomID:
Room ID number to move.
  • coordX/deltaX:
The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the X-axis.
  • coordY/deltaY:
The absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Y-axis.
  • coordZ/deltaZ:
(Optional) the absolute coordinate or the relative amount as a number to move the room in "room coordinates" along the Z-axis, if omitted the room is not moved in the z-axis at all.
  • absoluteNotRelativeMove:
(Optional) a boolean value (defaults to false if omitted) as to whether to move the room to the absolute coordinates (true) or the relative amount from its current location (false).
Returns
true on success or nil and an error message on failure, if successful it will also refresh the map display to show the result.
Example
-- move the first room one space to the east and two spaces to the north
moveRoom(1, 1, 2)

-- move the first room one space to the west, note the final boolean argument is unneeded
moveRoom(1, -1, 0, false)

-- move the first room three spaces to the west, and two south **of the center of the current level it is on in the map**:
moveRoom(1, -3, -2, true)

-- move the second room up three levels
moveRoom(2, 0, 0, 3)

-- move the second room one space to the west, note the last two arguments are unneeded
moveRoom(2, -1, 0, 0, false)

-- move the second room to the **center of the whole map**, note the last two arguments are required in this case:
moveRoom(2, 0, 0, 0, true)

-- all of the above will return the 'true'  boolean value assuming there are rooms with 1 and 2 as ID numbers

setupMapSymbolFont, PR #4038 closed

setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
configures the font used for symbols in the (2D) map.
See also: mapSymbolFontInfo()

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

Parameters
  • fontName one of:
  • - a string that is the family name of the font to use;
  • - the empty string "" to reset to the default {which is "Bitstream Vera Sans Mono"};
  • - a Lua nil as a placeholder to not change this parameter but still allow a following one to be modified.
  • onlyUseThisFont (optional) one of:
  • - a Lua boolean true to require Mudlet to use graphemes (character) only from the selected font. Should a requested grapheme not be included in the selected font then the font replacement character (�) might be used instead; note that under some circumstances it is possible that the OS (or Mudlet) provided color Emoji Font may still be used but that cannot be guaranteed across all OS platforms that Mudlet might be run on;
  • - a Lua boolean false to allow Mudlet to get a different glyph for a particular grapheme from the most suitable other font found in the system should there not be a glyph for it in the requested font. This is the default unless previously changed by this function or by the corresponding checkbox in the Profile Preferences dialogue for the profile concerned;
  • - a Lua nil as a placeholder to not change this parameter but still allow the following one to be modified.
  • scalingFactor (optional): a floating point value in the range 0.5 to 2.0 (default 1.0) that can be used to tweak the rectangular space that each different room symbol is scaled to fit inside; this might be useful should the range of characters used to make the room symbols be consistently under- or over-sized.
Returns
  • true on success
  • nil and an error message on failure. As the symbol font details are stored in the (binary) map file rather than the profile then this function will not work until a map is loaded (or initialised, by activating a map window).

Miscellaneous Functions

Miscellaneous functions.

compare, PR#7122 open

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

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

createVideoPlayer, PR #6439

createVideoPlayer([name of userwindow], x, y, width, height)
Creates a miniconsole window for the video player to render in, the with the given dimensions. One can only create one video player at a time (currently), and it is not currently possible to have a label on or under the video player - otherwise, clicks won't register.

Note Note: A video player may also be created through use of the Mud Client Media Protocol, the playVideoFile() API command, or adding a Geyser.VideoPlayer object to ones user interface such as the example below.

Note Note: The Main Toolbar will show a Video button to hide/show the video player, which is located in a userwindow generated through createVideoPlayer, embedded in a user interface, or a dock-able widget (that can be floated free to anywhere on the Desktop, it can be resized and does not have to even reside on the same monitor should there be multiple screens in your system). Further clicks on the Video button will toggle between showing and hiding the map whether it was created using the createVideo function or as a dock-able widget.

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

Mudlet VersionAvailable in Mudlet4.??+
Example
-- Create a 300x300 video player in the top-left corner of Mudlet
createVideoPlayer(0,0,300,300)

-- Alternative examples using Geyser.VideoPlayer
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({name="GUI.VideoPlayer", x = 0, y = 0, width = "25%", height = "25%"})
 
GUI.VideoPlayer = GUI.VideoPlayer or Geyser.VideoPlayer:new({
  name = "GUI.VideoPlayer",
  x = "70%", y = 0, -- edit here if you want to move it
  width = "30%", height = "50%"
}, GUI.Right)

loadVideoFile, PR #6439

loadVideoFile(settings table) or loadVideoFile(name, [url])
Loads video files from the Internet or the local file system to the "media" folder of the profile for later use with playVideoFile() and stopVideos(). Although files could be loaded or streamed directly at playing time from playVideoFile(), loadVideoFile() provides the advantage of loading files in advance.

Note Note: Video files consume drive space on your device. Consider using the streaming feature of playVideoFile() for large files.

Required Key Value Purpose
Yes name <file name>
  • Name of the media file.
  • May contain directory information (i.e. weather/maelstrom.mp4).
  • May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")
  • May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")
Maybe url <url>
  • Resource location where the media file may be downloaded.
  • Only required if file to load is not part of the profile or on the local file system.

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

Mudlet VersionAvailable in Mudlet4.??+
Example
---- Table Parameter Syntax ----

-- Download from the Internet
loadVideoFile({
    name = "TextInMotion-VideoSample-1080p.mp4"
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
})

-- OR download from the profile
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})

-- OR download from the local file system
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----

-- Download from the Internet
loadVideoFile(
    "TextInMotion-VideoSample-1080p.mp4"
    , "https://d2qguwbxlx1sbt.cloudfront.net/"
)

-- OR download from the profile
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")

-- OR download from the local file system
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")

playVideoFile, PR #6439

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

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

Mudlet VersionAvailable in Mudlet4.??+
Example
---- Table Parameter Syntax ----

-- Stream a video file from the Internet and play it.
playVideoFile({
    name = "TextInMotion-VideoSample-1080p.mp4"
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
    , stream = true
})

-- Play a video file from the Internet, storing it in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media) so you don't need to download it over and over.  You could add ", stream = false" below, but that is the default and is not needed.

playVideoFile({
    name = "TextInMotion-VideoSample-1080p.mp4"
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
})

-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playVideoFile({
    name = "TextInMotion-VideoSample-1080p.mp4"
})

-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile({
    name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"
    , volume = 75
})

-- OR copy once from the local file system, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile({
    name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"
    , volume = 75
})

-- OR download once from the Internet, and play a video stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "text" for stopping this unique video later
---- [tag] reference of "ambience" to stop any video later with the same tag
---- [continue] playing this video if another request for the same video comes in (false restarts it) 
---- [url] resource location where the file may be accessed on the Internet
---- [stream] download once from the Internet if the video does not exist in the profile's media directory when false (true streams from the Internet and will not download to the device) 
playVideoFile({
    name = "TextInMotion-VideoSample-1080p.mp4"
    , volume = nil -- nil lines are optional, no need to use
    , fadein = 10000
    , fadeout = 15000
    , start = 5000
    , loops = nil -- nil lines are optional, no need to use
    , key = "text"
    , tag = "ambience"
    , continue = true
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
    , stream = false
})
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----

-- Stream a video file from the Internet and play it.
playVideoFile(
    "TextInMotion-VideoSample-1080p.mp4"
    , nil -- volume
    , nil -- fadein
    , nil -- fadeout
    , nil -- start
    , nil -- loops
    , nil -- key
    , nil -- tag
    , true -- continue
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
    , false -- stream
)

-- Play a video file from the Internet, storing it in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media) so you don't need to download it over and over.
playVideoFile(
    "TextInMotion-VideoSample-1080p.mp4"
    , nil -- volume
    , nil -- fadein
    , nil -- fadeout
    , nil -- start
    , nil -- loops
    , nil -- key
    , nil -- tag
    , true -- continue
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
    , false -- stream
)

-- Play a video file stored in the profile's media directory (i.e. /Users/Tamarindo/mudlet-data/profiles/StickMUD/media)
playVideoFile(
    "TextInMotion-VideoSample-1080p.mp4"  -- name
)

-- OR copy once from the game's profile, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile(
    getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4" -- name
    , 75 -- volume
)

-- OR copy once from the local file system, and play a video file stored in the profile's media directory
---- [volume] of 75 (1 to 100)
playVideoFile(
    "C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name
    , 75 -- volume
)

-- OR download once from the Internet, and play a video stored in the profile's media directory
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
---- [key] reference of "text" for stopping this unique video later
---- [tag] reference of "ambience" to stop any video later with the same tag
---- [continue] playing this video if another request for the same video comes in (false restarts it) 
---- [url] resource location where the file may be accessed on the Internet
---- [stream] download once from the Internet if the video does not exist in the profile's media directory when false (true streams from the Internet and will not download to the device) 
playVideoFile(
    "TextInMotion-VideoSample-1080p.mp4" -- name
    , nil -- volume
    , 10000 -- fadein
    , 15000 -- fadeout
    , 5000 -- start
    , nil -- loops
    , "text" -- key
    , "ambience" -- tag
    , true -- continue
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
    , false -- stream
)


stopVideos, PR #6439

stopVideos(settings table)
Stop all videos (no filter), or videos that meet a combination of filters (name, key, and tag) intended to be paired with playVideoFile().
Required Key Value Purpose
No name <file name>
  • Name of the media file.
No key <key>
  • Uniquely identifies media files with a "key" that is bound to their "name" or "url".
  • Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
No tag <tag>
  • Helps categorize media.

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

Mudlet VersionAvailable in Mudlet4.??+
Example
---- Table Parameter Syntax ----

-- Stop all playing video files for this profile associated with the API
stopVideos()

-- Stop playing the text mp4 by name
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})

-- Stop playing the unique sound identified as "text"
stopVideos({
    name = nil  -- nil lines are optional, no need to use
    , key = "text" -- key
    , tag = nil  -- nil lines are optional, no need to use
})
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----

-- Stop all playing video files for this profile associated with the API
stopVideos()

-- Stop playing the text mp4 by name
stopVideos("TextInMotion-VideoSample-1080p.mp4")

-- Stop playing the unique sound identified as "text"
stopVideos(
    nil -- name
    , "text" -- key
    , nil -- tag
)


getCustomLoginTextId, PR #3952 open

getCustomLoginTextId()

Returns the Id number of the custom login text setting from the profile's preferences. Returns 0 if the option is disabled or a number greater than that for the item in the table; note it is possible if using an old saved profile in the future that the number might be higher than expected. As a design policy decision it is not permitted for a script to change the setting, this function is intended to allow a script or package to check that the setting is what it expects.

Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function, a replacement for which is shown below.

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

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

Only one custom login text has been defined initially:

Predefined custom login texts
Id Custom text Introduced in Mudlet version
1 "connect {character name} {password}" TBD

The addition of further texts would be subject to negotiation with the Mudlet Makers.

Example
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
function doLogin()
  if getCustomLoginTextId() ~= 1 then
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
    echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
  else
    tempTime(2.0, [[sendCustomLoginText()]], 1)
  end
end

sendCharacterName, PR #3952 open

sendCharacterName()

Sends the name entered into the "Character name" field on the Connection Preferences form directly to the game server. Returns true unless there is nothing set in that entry in which case a nil and an error message will be returned instead.

Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function that may be replaced for more sophisticated requirements.

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

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

sendCharacterPassword, PR #3952 open

sendCharacterPassword()

Sends the password entered into the "Password" field on the Connection Preferences form directly to the game server. Returns true unless there is nothing set in that entry or it is too long after (or before) a connection was successfully made in which case a nil and an error message will be returned instead.

Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function, reproduced below, that may be replaced for more sophisticated requirements.

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

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

Example
-- The default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
function doLogin()
  if getCharacterName() ~= "" then
    tempTime(2.0, [[sendCharacterName()]], 1)
    tempTime(3.0, [[sendCharacterPassword()]], 1)
  end
end

sendCustomLoginText, PR #3952 open

sendCustomLoginText()

Sends the custom login text (which does NOT depend on the user's choice of GUI language) selected in the preferences for this profile. The {password} (and {character name} if present) fields will be replaced with the values entered into the "Password" and "Character name" fields on the Connection Preferences form and then sent directly to the game server. Returns true unless there is nothing set in either of those entries (though only if required for the character name) or it is too long after (or before) a connection was successfully made or if the custom login feature is disabled, in which case a nil and an error message will be returned instead.

Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined doLogin() function, a replacement for which is shown below.

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

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

Only one custom login text has been defined initially:

Predefined custom login texts
Id Custom text Introduced in Mudlet version
1 "connect {character name} {password}" TBD

The addition of further texts would be subject to negotiation with the Mudlet Makers.

Example
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
function doLogin()
  if getCustomLoginTextId() ~= 1 then
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
    echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
  else
    tempTime(2.0, [[sendCustomLoginText()]], 1)
  end
end

Mudlet Object Functions

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

ancestors, new in PR #6726

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

findItems, new in PR #6742

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

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

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

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

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

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

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

getExitStubsNames, new in PR #7519

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

getProfiles, new in PR #7423

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

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

isActive, modified by PR #6726

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

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

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

isAncestorsActive, new in PR #6726

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

loadProfile, new in PR #7423

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

clearProfileInformation(), new in PR #7511

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

getProfileInformation(), new in PR #7511

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

setProfileInformation(), new in PR #7511

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

Networking Functions

A collection of functions for managing networking.

sendSocket revised in PR #7066 (Open)

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

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

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

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

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

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

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

-- This function is still being written up.

feedTelnet added in PR #7066 (Open)==

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

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

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

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

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

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

-- This function is still being written up.

String Functions

These functions are used to manipulate strings.

Table Functions

These functions are used to manipulate tables. Through them you can add to tables, remove values, check if a value is present in the table, check the size of a table, and more.

Text to Speech Functions

These functions are used to create sound from written words. Check out our Text-To-Speech Manual for more detail on how this all works together.

UI Functions

These functions are used to construct custom user GUIs. They deal mainly with miniconsole/label/gauge creation and manipulation as well as displaying or formatting information on the screen.

cecho2decho PR#6849 merged

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

cecho2hecho PR#6849 merged

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

cecho2html PR#6849 merged

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

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

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

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

decho2cecho PR#6849 merged

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

decho2hecho PR#6849 merged

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

decho2html PR#6849 merged

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

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

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

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

deleteMultiline PR #6779 merged

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

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

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

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

echoPopup, revised in PR #6946

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

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

-- one can also provide helpful information

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

hecho2cecho PR#6849 merged

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

hecho2decho PR#6849 merged

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

hecho2html PR#6849 merged

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

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

-- convert the hecho string to an html one, using the default formatting of testLabel created above
local htmlString = hecho2html(hechoString, testLabel:getFormat())

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

insertPopup, revised in PR #6925

insertPopup([windowName], text, {commands}, {hints}[{, tool-tips}][, useCurrentFormatElseDefault])
Creates text with a left-clickable link, and a right-click menu for more options at the end of the current line, like echo. The added text, upon being left-clicked, will do the first command in the list. Upon being right-clicked, it'll display a menu with all possible commands. The menu will be populated with hints, one for each line; if a tool-tips table is not provided the same hints will also be listed one-per-line as a tool-tip but if a matching number of tool-tips are provided they will be concatenated to provide a tool-tip when the text is hovered over by the pointer - these tool-tips can be rich-text to produce information formatted with additional content in the same manner as labels.
Parameters
  • windowName:
(optional) name of the window as a string to echo to. Use either main or omit for the main window, or the miniconsole's or user-window's name otherwise.
  • text:
the text string to display.
  • {commands}:
a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. {[[send("hello")]], function() echo("hi!") end}.
  • {hints}:
a table of strings which will be shown on the right-click menu (and popup if no {tool-tips} table is provided). If a particular position in both the commands and hints table are both the empty string "" but there is something in the tool-tips table, no entry for that position will be made in the context menu but the tool-tip can still display something which can include images or text.
  • {tool-tips}:
(optional) a table of possibly rich-text strings which will be shown on the popup if provided.
  • useCurrentFormatElseDefault:
(optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if true or the link default (blue underline) if false, if omitted the default format is used.

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

Example
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})

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

-- one can also provide helpful information

-- todo: an example with rich-text in the tool-tips(s)

Discord Functions

All functions to customize the information Mudlet displays in Discord's rich presence interface. For an overview on how all of these functions tie in together, see our Discord scripting overview.

Mud Client Media Protocol

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

Supported Protocols

Events

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

sysSettingChanged, PR #7476

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

Currently implemented sysSettingChanged events are;

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

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

sysMapAreaChanged, PR #6615

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

Mudlet VersionAvailable in Mudlet ?.??+

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

sysMapWindowMousePressEvent, PR #6962

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

Mudlet VersionAvailable in Mudlet ?.??+

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

sysWindowOverflowEvent, PR #6872

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

Mudlet VersionAvailable in Mudlet ?.??+

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