Difference between revisions of "Area 51"

From Mudlet
Jump to navigation Jump to search
 
(368 intermediate revisions by 12 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 11: Line 17:
 
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.
 
:These functions are generic functions used in normal scripting. These deal with mainly everyday things, like sending stuff and echoing to the screen.
  
==printDebug==
+
=Database Functions=
; printDebug(msg, [showStackTrace])
+
:A collection of functions for helping deal with the database.
  
:Prints a debug message in green to the error console in the script editor only. Does not echo to the debug window or the main console. Includes stack trace if showStackTrace is included and not nil or false.
+
=Date/Time Functions=
 +
: A collection of functions for handling date & time.
  
;See also: [[Manual:Lua_Functions#printError|printError]], [[Manual:Lua_Functions#debugc|debugc]]
+
=File System Functions=
 +
: A collection of functions for interacting with the file system.
  
{{MudletVersion|4.14}}
+
=Mapper Functions=
 +
: A collection of functions that manipulate the mapper and its related features.
 +
 
 +
==createMapLabel, merged #7598==
 +
;labelID = createMapLabel(areaID, text, posX, posY, posZ, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue[, zoom, fontSize, showOnTop, noScaling, fontName, foregroundTransparency, backgroundTransparency, temporary, outlineRed, outlineGreen, outlineBlue])
 +
 
 +
:Creates a text label on the map at given coordinates, with the given background and foreground colors. It can go above or below the rooms, scale with zoom or stay a static size. From Mudlet 4.17.0 an additional parameter (assumed to be false if not given from then) makes the label NOT be saved in the map file which, if the image can be regenerated on future loading from a script can reduce the size of the saved map somewhat. It returns a label ID that you can use later for deleting it.
  
{{note}} This will not be echoed to the main console even if the option to echo Lua errors to the main console is turned on. Does not echo to the debug window. As such you can use it for debugging information without fear it will be shown unless someone goes looking for errors.
+
:The coordinates 0,0 are in the middle of the map, and are in sync with the room coordinates - so using the x,y values of [[#getRoomCoordinates|getRoomCoordinates()]] will place the label near that room.
 +
 
 +
: See also: [[#getMapLabel|getMapLabel()]], [[#getMapLabels|getMapLabels()]], [[#deleteMapLabel|deleteMapLabel]], [[#createMapImageLabel|createMapImageLabel()]]
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
<div style="font-weight:bold;line-height:1.6;">Historical Version Note</div>
 +
<div class="mw-collapsible-content">
 +
{{note}} Some changes were done prior to 4.13 (which exactly? function existed before!) - see corresponding PR and update here!
 +
</div></div>
  
 
;Parameters
 
;Parameters
* ''msg:''
+
* ''areaID:''
: string to echo to the error console
+
: Area ID where to put the label.
* ''showStackTrace:''
+
* ''text:''
: (optional) boolean true if you want to include the stack trace, leave off if you do not.
+
: The text to put into the label. To get a multiline text label add a '\n' between the lines.
 +
* ''posX, posY, posZ:''
 +
: Position of the label in (floating point numbers) room coordinates.
 +
* ''fgRed, fgGreen, fgBlue:''
 +
: Foreground color or text color of the label.
 +
* ''bgRed, bgGreen, bgBlue:''
 +
: Background color of the label.
 +
* ''zoom:''
 +
: (optional) Zoom factor of the label if noScaling is false. Higher zoom will give higher resolution of the text and smaller size of the label. Default is 30.0.
 +
* ''fontSize:''
 +
: (optional, but needed if zoom is provided) Size of the font of the text. Default is 50.
 +
* ''showOnTop:''
 +
: (optional) If true the label will be drawn on top of the rooms and if it is false the label will be drawn as a background, defaults to true if not given.
 +
* ''noScaling:''
 +
: (optional) If true the label will have the same size when you zoom in and out in the mapper, If it is false the label will scale when you zoom the mapper, defaults to true if not given.
 +
* ''fontName:''
 +
: (optional) font name to use.
 +
* ''foregroundTransparency''
 +
: (optional) transparency of the text on the label, defaults to 255 (in range of 0 to 255) or fully opaque if not given.
 +
* ''backgroundTransparency''
 +
: (optional) transparency of the label background itself, defaults to 50 (in range of 0 to 255) or significantly transparent if not given.
 +
* ''temporary''
 +
: (optional) if true does not save the image that the label makes in map save files, defaults to false if not given, or for prior versions of Mudlet.
 +
* ''outlineRed, outlineGreen, outlineBlue''
 +
: (optional) the outline colour of the displayed text
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- print a debug message to the error console for troubleshooting purposes, when you don't want to echo the information to the main screen.
+
-- the first 50 is some area id, the next three 0,0,0 are coordinates - middle of the area
-- the only difference between this and debugc is this includes information on the script/alias/trigger/etc and line it was called from, whereas debugc does not.
+
-- 255,0,0 would be the foreground in RGB, 23,0,0 would be the background RGB
printDebug("Switching to chaos mode")
+
-- zoom is only relevant when when you're using a label of a static size, so we use 0
 +
-- and we use a font size of 20 for our label, which is a small medium compared to the map
 +
local labelid = createMapLabel( 50, "my map label", 0,0,0, 255,0,0, 23,0,0, 0,20)
  
-- Want to record that something occurred, and include stacktrace so you can see what path the code was taking, but you don't want to halt execution or have it show up in main screen or in scary red.
+
-- to create a multi line text label add '\n' between lines
printDebug("Something unexpected occurred but we can recover from it. Still, we want to be able to notice and troubleshoot it with extra information.", true)
+
-- the position is placed somewhat to the northeast of the center of the map
 +
-- this label will be scaled as you zoom the map.
 +
local labelid = createMapLabel( 50, "1. Row One\n2. Row 2", .5,5.5,0, 255,0,0, 23,0,0, 30,50, true, false)
 +
 
 +
local x,y,z = getRoomCoordinates(getPlayerRoom())
 +
createMapLabel(getRoomArea(getPlayerRoom()), "my map label", x,y,z, 255,0,0, 23,0,0, 0,20, false, true, "Ubuntu", 255, 100)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==printError==
+
-- create a temporary, multiline label with purple text and a white outline
; printError(msg, [showStackTrace], [haltExecution])
+
lua createMapLabel(1, "This is a really long text\nwith multiple lines.", 0, 0, 0, 125, 0, 125, 0, 0, 0, 50, 48, true, false, "Noto Sans", 255, 0, true, 255, 255, 255)
 +
 
  
:Prints an error message in red to the error console in the script editor. Can optionally include stacktrace information and halt execution.
+
==mapSymbolFontInfo, PR #4038 closed==
 +
;mapSymbolFontInfo()
 +
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]
  
;See also: [[Manual:Lua_Functions#printDebug|printDebug]], [[Manual:Lua_Functions#debugc|debugc]]
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
  
{{MudletVersion|4.14}}
+
;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).
  
{{note}} This WILL be echoed to the main console if the option to echo Lua errors to the main console is turned on. You should not use this for idle debugging information, but actual errors that may put big red error lines in the main 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
 
;Parameters
* ''msg:''
+
* ''areaID/Name:''
: string to echo to the error console
+
: Area ID as number or AreaName as string containing the map label.
* ''showStackTrace:''
+
 
: (optional) true if you want to include the stack trace, leave off if you do not.
+
* ''labelID/Text:''
* ''haltExecution:''
+
: 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.
: (optional) true if you want to halt execution. You must pass a value for showStackTrace in order to halt execution.
+
 
 +
* ''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
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- print an error message but do not include extra stack information or halt execution.
+
-- move the first label in the area with the ID number of 2, three spaces to the east and four spaces to the north
-- this is similar to debugc except it include more information on the place it was called from
+
moveMapLabel(0, 2, 3.0, 4.0)
-- and will show up in red and echo to the main console if the option for errors to echo there is selected.
+
 
printError("Your maxhp is below your currenthp and our game doesn't allow for that. HAX?!")
+
-- 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)
  
-- Something bad happened, for sure, but your script can recover.
+
-- 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**:
-- Make sure this is something important enough it might make it to the main window as a big red error.
+
moveRoom(1, 2, -3.5, -2.0, true)
-- but we are not halting execution, since we can carry on in some capacity
 
printError("gmcp values for this thing went missing, will carry on using defaults but you should tell somebody about this.", true)
 
  
-- print an error message to the error console for troubleshooting purposes.
+
-- move the second label in the area with the ID number of 2, up three levels
-- Prints stack trace for troubleshooting and halts execution (because you cannot continue without the configuration, presumably)
+
moveRoom(1, 2, 0.0, 0.0, 3.0)
-- similar to using error(msg) but includes the stacktrace information.
 
printError("Our entire configuration seems to have gone missing!", true, true)
 
  
 +
-- 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>
 
</syntaxhighlight>
  
=Database Functions=
+
==moveRoom, PR #6010 open==
:A collection of functions for helping deal with the database.
+
;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'').
  
=Date/Time Functions=
+
;Returns
: A collection of functions for handling date & time.
+
: ''true'' on success or ''nil'' and an error message on failure, if successful it will also refresh the map display to show the result.
  
=File System Functions=
+
;Example
: A collection of functions for interacting with the file system.
+
<syntaxhighlight lang="lua">
 +
-- move the first room one space to the east and two spaces to the north
 +
moveRoom(1, 1, 2)
  
=Mapper Functions=
+
-- move the first room one space to the west, note the final boolean argument is unneeded
: A collection of functions that manipulate the mapper and its related features.
+
moveRoom(1, -1, 0, false)
  
==mapSymbolFontInfo==
+
-- 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**:
;mapSymbolFontInfo()
+
moveRoom(1, -3, -2, true)
: See also: [[#setupMapSymbolFont|setupMapSymbolFont()]]
 
  
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/4038
+
-- move the second room up three levels
 +
moveRoom(2, 0, 0, 3)
  
;returns
+
-- move the second room one space to the west, note the last two arguments are unneeded
* either a table of information about the configuration of the font used for symbols in the (2D) map, the elements are:
+
moveRoom(2, -1, 0, 0, false)
:* ''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).
+
-- 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==
+
==setupMapSymbolFont, PR #4038 closed==
 
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
 
;setupMapSymbolFont(fontName[, onlyUseThisFont[, scalingFactor]])
 
:configures the font used for symbols in the (2D) map.
 
:configures the font used for symbols in the (2D) map.
Line 129: Line 242:
 
: Miscellaneous functions.
 
: Miscellaneous functions.
  
==deleteAllNamedEventHandlers==
+
==createVideoPlayer, PR #6439==
; deleteAllNamedEventHandlers(handlerName)
+
;createVideoPlayer([name of userwindow], x, y, width, height)
  
:Deletes all named event handlers and prevents them from firing any more. Information is deleted and cannot be retrieved.
+
: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.
  
;See also: [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]], [[Manual:Lua_Functions#stopNamedEventHandler|stopNamedEventHandler()]]
+
{{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.
  
{{MudletVersion|4.14}}
+
{{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: [[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]]
 +
 
 +
{{MudletVersion|4.??}}
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
deleteAllNamedEventHandlers() -- emergency stop or debugging situation, most likely.
+
-- 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)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==deleteNamedEventHandler==
+
==loadVideoFile, PR #6439==
; success = deleteNamedEventHandler(handlerName)
+
;loadVideoFile(settings table) or loadVideoFile(name, [url])
 +
:Loads video files from the Internet or the local file system to the "media" folder of the profile for later use with [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] and [[Manual:Miscellaneous_Functions#stopVideos|stopVideos()]]. Although files could be loaded or streamed directly at playing time from [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]], loadVideoFile() provides the advantage of loading files in advance.
  
:Deletes a named event handler with name handlerName and prevents it from firing any more. Information is deleted and cannot be retrieved.
+
{{note}} Video files consume drive space on your device. Consider using the streaming feature of [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]] for large files.
  
;See also: [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]], [[Manual:Lua_Functions#stopNamedEventHandler|stopNamedEventHandler()]]
+
{| class="wikitable"
 +
!Required
 +
!Key
 +
!Value
 +
! style="text-align:left;" |Purpose
 +
|- style="color: green;"
 +
| style="text-align:center;" |Yes
 +
|name
 +
|<file name>
 +
| style="text-align:left;" |
 +
*Name of the media file.
 +
*May contain directory information (i.e. weather/maelstrom.mp4).
 +
*May be part of the profile (i.e. getMudletHomeDir().. "/congratulations.mp4")
 +
*May be on the local device (i.e. "C:/Users/YourNameHere/Movies/nevergoingtogiveyouup.mp4")
 +
|- style="color: blue;"
 +
| style="text-align:center;" |Maybe
 +
|url
 +
|<url>
 +
| style="text-align:left;" |
 +
*Resource location where the media file may be downloaded.
 +
*Only required if file to load is not part of the profile or on the local file system.
 +
|-
 +
|}
  
{{MudletVersion|4.14}}
+
See also: [[Manual:Miscellaneous_Functions#playSoundFile|loadSoundFile()]], [[Manual:Miscellaneous Functions#loadMusicFile|loadMusicFile()]], [[Manual:Miscellaneous Functions#playSoundFile|playSoundFile()]], [[Manual:Miscellaneous_Functions#playMusicFile|playMusicFile()]], [[Manual:Miscellaneous Functions#playVideoFile|playVideoFile()]], [[Manual:Miscellaneous_Functions#stopSounds|stopSounds()]], [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]], [[Manual:Miscellaneous Functions#stopVideos|stopVideos()]], [[Manual:Miscellaneous Functions#createVideoPlayer|createVideoPlayer()]], [[Manual:Miscellaneous_Functions#purgeMediaCache|purgeMediaCache()]], [[Manual:Scripting#MUD_Client_Media_Protocol|Mud Client Media Protocol]]
  
;Parameters
+
{{MudletVersion|4.??}}
* ''handlerName:''
 
: The name of the handler to stop. Same as used when you called [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]]
 
  
;Returns
 
* true if successful, false if it didn't exist
 
 
;Example
 
;Example
 +
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local deleted = deletedNamedEventHandler("DemonVitals")
+
---- Table Parameter Syntax ----
if deleted then
 
  cecho("DemonVitals deleted forever!!")
 
else
 
  cecho("DemonVitals doesn't exist and so could not be deleted.")
 
end
 
</syntaxhighlight>
 
  
==getCharacterName==
+
-- Download from the Internet
;getCharacterName()
+
loadVideoFile({
 +
    name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
})
  
: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.
+
-- OR download from the profile
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.
+
loadVideoFile({name = getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4"})
  
:See also: [[#sendCharacterName|sendCharacterName()]], [[#sendCharacterPassword|sendCharacterPassword()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#getCustomLoginTextId|getCustomLoginTextId()]].
+
-- OR download from the local file system
 +
loadVideoFile({name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"})
 +
</syntaxhighlight>
 +
<syntaxhighlight lang="lua">
 +
---- Ordered Parameter Syntax of loadVideoFile(name[, url]) ----
  
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
+
-- Download from the Internet
 +
loadVideoFile(
 +
    "TextInMotion-VideoSample-1080p.mp4"
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
)
  
;Example
+
-- OR download from the profile
<syntaxhighlight lang="lua">
+
loadVideoFile(getMudletHomeDir().. "/TextInMotion-VideoSample-1080p.mp4")
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.
+
-- OR download from the local file system
A small twittering bird settles on your shoulder and starts to look adoringly at you.
+
loadVideoFile("C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4")
A light brown faun gambles around you and then nuzzles your hand.
 
A tawny long-haired cat saunters over and start to rub itself against your ankles.
 
A small twittering bird settles on your shoulder and starts to look adoringly at you.
 
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>
 
</syntaxhighlight>
  
==getCustomLoginTextId==
+
==playVideoFile, PR #6439==
;getCustomLoginTextId()
+
;playVideoFile(settings table)
 +
:Plays video files from the Internet or the local file system for later use with [[Manual:Miscellaneous_Functions#stopMusic|stopMusic()]]. Video files may be downloaded to the device and played, or streamed from the Internet when the value of the <code>stream</code> parameter is <code>true</code>.
  
Returns the Id number of the custom login text setting from the profile's preferences. Returns ''0'' if the option is disabled or a number greater than that for the item in the table; note it is possible if using an old saved profile in the future that the number might be higher than expected. As a design policy decision it is not permitted for a script to change the setting, this function is intended to allow a script or package to check that the setting is what it expects.
 
 
Introduced along with four other functions to enable game server log-in to be scripted with the simultaneous movement of that functionality from the Mudlet application core code to a predefined ''doLogin()'' function, a replacement for which is shown below.
 
:See also: [[#getCharacterName|getCharacterName()]], [[#sendCharacterName|sendCharacterName()]], [[#sendCustomLoginText|sendCustomLoginText()]], [[#sendPassword|sendPassword()]].
 
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 
 
Only one custom login text has been defined initially:
 
 
{| class="wikitable"
 
{| class="wikitable"
|+ Predefined custom login texts
+
!Required
 +
!Key
 +
!Value
 +
!Default
 +
! style="text-align:left;" |Purpose
 +
|- style="color: green;"
 +
| style="text-align:center;" |Yes
 +
|name
 +
|<file name>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Name of the media file.
 +
*May contain directory information (i.e. weather/maelstrom.mp4).
 +
*May be part of the profile (i.e. getMudletHomeDir().. "/cow.mp4")
 +
* May be on the local device (i.e. "C:/Users/YourNameHere/Documents/nevergoingtogiveyouup.mp4")
 +
*Wildcards ''*'' and ''?'' may be used within the name to randomize media files selection.
 +
|-
 +
| style="text-align:center;" |No
 +
| volume
 +
|1 to 100
 +
|50
 +
| style="text-align:left;" |
 +
*Relative to the volume set on the player's client.
 
|-
 
|-
! Id !! Custom text !! Introduced in Mudlet version
+
| style="text-align:center;" |No
 +
|fadein
 +
|<msec>
 +
|
 +
|
 +
*Volume increases, or fades in, ranged across a linear pattern from one to the volume set with the "volume" key.
 +
*Start position:  Start of media.
 +
*End position:  Start of media plus the number of milliseconds (msec) specified.
 +
*1000 milliseconds = 1 second.
 +
|-
 +
| style="text-align:center;" |No
 +
|fadeout
 +
|<msec>
 +
|
 +
|
 +
*Volume decreases, or fades out, ranged across a linear pattern from the volume set with the "volume" key to one.
 +
*Start position:  End of the media minus the number of milliseconds (msec) specified.
 +
*End position:  End of the media.
 +
*1000 milliseconds = 1 second.
 +
|-
 +
| style="text-align:center;" |No
 +
|start
 +
|<msec>
 +
| 0
 +
| style="text-align:left;" |
 +
*Begin play at the specified position in milliseconds.
 +
|-
 +
| style="text-align:center;" |No
 +
|loops
 +
| -1, or >= 1
 +
|1
 +
| style="text-align:left;" |
 +
*Number of iterations that the media plays.
 +
*A value of -1 allows the media to loop indefinitely.
 +
|-
 +
| style="text-align:center;" |No
 +
|key
 +
|<key>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Uniquely identifies media files with a "key" that is bound to their "name" or "url".
 +
*Halts the play of current media files with the same "key" that have a different "name" or "url" while this media plays.
 +
|-
 +
| style="text-align:center;" |No
 +
|tag
 +
|<tag>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Helps categorize media.
 +
|-
 +
| style="text-align:center;" |No
 +
|continue
 +
|true or false
 +
|true
 +
| style="text-align:left;" |
 +
*Continues playing matching new video files when true.
 +
*Restarts matching new video files when false.
 +
|- style="color: blue;"
 +
| style="text-align:center;" |Maybe
 +
|url
 +
|<url>
 +
|&nbsp;
 +
| style="text-align:left;" |
 +
*Resource location where the media file may be downloaded.
 +
*Only required if the file is to be downloaded remotely or for streaming from the Internet.
 +
|- style="color: blue;"
 +
| style="text-align:center;" |Maybe
 +
|stream
 +
|true or false
 +
|false
 +
| style="text-align:left;" |
 +
*Streams files from the Internet when true.
 +
*Download files when false (default).
 +
*Used in combination with the `url` key.
 
|-
 
|-
| 1 || "connect {character name} {password}" || TBD
 
 
|}
 
|}
  
The addition of further texts would be subject to negotiation with the Mudlet Makers.
+
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.??}}
  
 
;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:
+
---- Table Parameter Syntax ----
function doLogin()
+
 
  if getCustomLoginTextId() ~= 1 then
+
-- Stream a video file from the Internet and play it.
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
+
playVideoFile({
     echo("\nUnable to login - please select the 'connect {character name} {password}` custom login option in the profile preferences.\n")
+
     name = "TextInMotion-VideoSample-1080p.mp4"
  else
+
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
     tempTime(2.0, [[sendCustomLoginText()]], 1)
+
     , stream = true
  end
+
})
end
 
</syntaxhighlight>
 
  
==getNewIDManager==
+
-- 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.
; getNewIDManager()
 
  
:Returns an IDManager object, for manager your own set of named events and timers isolated from the rest of the profile.
+
playVideoFile({
 +
    name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
})
  
;See also: [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]], [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
+
-- 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"
 +
})
  
{{MudletVersion|4.14}}
+
-- 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
 +
})
  
;Returns
+
-- OR copy once from the local file system, and play a video file stored in the profile's media directory
* an IDManager for managing your own named events and timers
+
---- [volume] of 75 (1 to 100)
 +
playVideoFile({
 +
    name = "C:/Users/Tamarindo/Movies/TextInMotion-VideoSample-1080p.mp4"
 +
    , volume = 75
 +
})
  
;Example
+
-- OR download once from the Internet, and play a video stored in the profile's media directory
 +
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
 +
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
 +
---- [start] 5 seconds after position 0 (fadein scales its volume increase over a shorter duration, too)
 +
---- [key] reference of "text" for stopping this unique video later
 +
---- [tag] reference of "ambience" to stop any video later with the same tag
 +
---- [continue] playing this video if another request for the same video comes in (false restarts it)
 +
---- [url] resource location where the file may be accessed on the Internet
 +
---- [stream] download once from the Internet if the video does not exist in the profile's media directory when false (true streams from the Internet and will not download to the device)
 +
playVideoFile({
 +
    name = "TextInMotion-VideoSample-1080p.mp4"
 +
    , volume = nil -- nil lines are optional, no need to use
 +
    , fadein = 10000
 +
    , fadeout = 15000
 +
    , start = 5000
 +
    , loops = nil -- nil lines are optional, no need to use
 +
    , key = "text"
 +
    , tag = "ambience"
 +
    , continue = true
 +
    , url = "https://d2qguwbxlx1sbt.cloudfront.net/"
 +
    , stream = false
 +
})
 +
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
demonnic = demonnic or {}
+
---- Ordered Parameter Syntax of playVideoFile(name[,volume][,fadein][,fadeout][,loops][,key][,tag][,continue][,url][,stream]) ----
demonnic.IDManager = getNewIDManager()
 
local idm = demonnic.IDManager
 
-- assumes you have defined demonnic.vitalsUpdate and demonnic.balanceChecker as functions
 
idm:registerEvent("DemonVitals", "gmcp.Char.Vitals", demonnic.vitalsUpdate)
 
idm:registerTimer("Balance Check", 1, demonnic.balanceChecker)
 
idm:stopEvent("DemonVitals")
 
</syntaxhighlight>
 
  
==getNamedEventHandlers==
+
-- Stream a video file from the Internet and play it.
; handlers = getNamedEventHandlers()
+
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
 +
)
  
:Returns a list of all the named event handlers' names as a table.
+
-- 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
 +
)
  
;See also: [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]]
+
-- 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
 +
)
  
{{MudletVersion|4.14}}
+
-- 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
 +
)
  
;Returns
+
-- OR copy once from the local file system, and play a video file stored in the profile's media directory
* a table of handler names. { "DemonVitals", "DemonInv" } for example. {} if none are registered
+
---- [volume] of 75 (1 to 100)
 +
playVideoFile(
 +
    "C:/Users/Tamarindo/Documents/TextInMotion-VideoSample-1080p.mp4" -- name
 +
    , 75 -- volume
 +
)
  
;Example
+
-- OR download once from the Internet, and play a video stored in the profile's media directory
<syntaxhighlight lang="lua">
+
---- [fadein] and increase the volume from 1 at the start position to default volume up until the position of 10 seconds
  local handlers = getNamedEventHandlers()
+
---- [fadeout] and decrease the volume from default volume to one, 15 seconds from the end of the video
  display(handlers)
+
---- [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
  registerNamedEventHandler("Test1", "testEvent", "testFunction")
+
---- [tag] reference of "ambience" to stop any video later with the same tag
  registerNamedEventHandler("Test2", "someOtherEvent", myHandlerFunction)
+
---- [continue] playing this video if another request for the same video comes in (false restarts it)  
  handlers = getNamedEventHandlers()
+
---- [url] resource location where the file may be accessed on the Internet
  display(handlers)
+
---- [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)  
  -- { "Test1", "Test2" }
+
playVideoFile(
 +
    "TextInMotion-VideoSample-1080p.mp4" -- name
 +
    , nil -- volume
 +
    , 10000 -- fadein
 +
    , 15000 -- fadeout
 +
    , 5000 -- start
 +
    , nil -- loops
 +
    , "text" -- key
 +
    , "ambience" -- tag
 +
    , true -- continue
 +
    , "https://d2qguwbxlx1sbt.cloudfront.net/" -- url
 +
    , false -- stream
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==registerNamedEventHandler==
 
; success = registerNamedEventHandler(handlerName, eventName, functionReference, [oneShot])
 
  
:Registers a named event handler with name handlerName. Named event handlers are protected from duplication and can be stopped and resumed, unlike anonymous event handlers.
+
==stopVideos, PR #6439==
 +
;stopVideos(settings table)
 +
:Stop all videos (no filter), or videos that meet a combination of filters (name, key, and tag) intended to be paired with [[Manual:Miscellaneous_Functions#playVideoFile|playVideoFile()]].
  
;See also: [[Manual:Lua_Functions#registerAnonymousEventHandler|registerAnonymousEventHandler()]], [[Manual:Lua_Functions#stopNamedEventHandler|stopNamedEventHandler()]], [[Manual:Lua_Functions#resumeNamedEventHandler|resumeNamedEventHandler()]], [[Manual:Lua_Functions#deleteNamedEventHandler|deleteNamedEventHandler()]], [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
+
{| class="wikitable"
 +
!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.
 +
|-
 +
|}
 +
 
 +
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.14}}
+
{{MudletVersion|4.??}}
 +
 
 +
;Example
 +
 
 +
<syntaxhighlight lang="lua">
 +
---- Table Parameter Syntax ----
  
;Parameters
+
-- Stop all playing video files for this profile associated with the API
* ''handlerName:''
+
stopVideos()
: The name of the handler. Used to reference the handler in other functions and prevent duplicates. Recommended you use descriptive names, "hp" is likely to collide with something else, "DemonVitals" less so.
 
* ''eventName:''
 
: The name of the event the handler responds to. [[Manual:Event_Engine#Mudlet-raised_events|See here]] for a list of Mudlet-raised events.
 
* ''functionReference:''
 
: The function reference to run when the event comes in. Can be the name of a function, "handlerFuncion", or the lua function itself.
 
* ''oneShot:''
 
: (optional) if true, the event handler will only fire once when the event is raised. If you need to extend a one shot event handler for "one more check" you can have the handler return true, and it will keep firing until the function does not return true.
 
  
;Returns
+
-- Stop playing the text mp4 by name
* true if successful, otherwise errors.
+
stopVideos({name = "TextInMotion-VideoSample-1080p.mp4"})
  
;Example
+
-- 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
 +
})
 +
</syntaxhighlight>
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
-- register a named event handler. Will call demonVitalsHandler(eventName, ...) when gmcp.Char.Vitals is raised.
+
---- Ordered Parameter Syntax of stopVideos([name][,key][,tag]) ----
local ok = registerNamedEventHandler("DemonVitals", "gmcp.Char.Vitals", "demonVitalsHandler")
 
if ok then
 
  cecho("Vitals handler switched to demonVitalsHandler")
 
end
 
  
-- something changes later, and we want to handle vitals with another function, demonBlackoutHandler()
+
-- Stop all playing video files for this profile associated with the API
-- note we do not use "" around demonBlackoutHandler but instead pass the function itself. Both work.
+
stopVideos()
-- using the same handlerName ("DemonVitals") means it will automatically unregister the old handler
 
-- and reregister it using the new information.
 
local ok = registerNamedEventHandler("DemonVitals", "gmcp.Char.Vitals", demonBlackoutHandler)
 
if ok then
 
  cecho("Vitals handler switched to demonBlackoutHandler")
 
end
 
  
-- Now you want to check your inventory, but you only want to do it once, so you pass the optional oneShot as true
+
-- Stop playing the text mp4 by name
local function handleInv()
+
stopVideos("TextInMotion-VideoSample-1080p.mp4")
  local list = gmcp.Char.Items.List
 
  if list.location ~= "inventory" then
 
    return true -- if list.location is, say "room" then we need to keep responding until it's "inventory"
 
  end
 
  display(list.items) -- you would probably store values and update displays or something, but here I'll just show the data as it comes in
 
end
 
  
-- you can ignore the response from registerNamedEventHandler if you want, it's always going to be true
+
-- Stop playing the unique sound identified as "text"
-- unless there is an error, in which case it throws the error and halts execution anyway. The return is
+
stopVideos(
-- in part for feedback when using the lua alias or other REPL window.
+
    nil -- name
registerNamedEventHandler("DemonInvCheck", "gmcp.Char.Items.List", handleInv, true)
+
    , "text" -- key
 +
    , nil -- tag
 +
)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==resumeNamedEventHandler==
 
; success = resumeNamedEventHandler(handlerName)
 
  
:Resumes a named event handler with name handlerName and causes it to start firing once more
+
==getCustomLoginTextId, PR #3952 open==
 +
;getCustomLoginTextId()
  
;See also: [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]], [[Manual:Lua_Functions#stopNamedEventHandler|stopNamedEventHandler()]]
+
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.
  
{{MudletVersion|4.14}}
+
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()]].
  
;Parameters
+
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
* ''handlerName:''
+
 
: The name of the handler to resume. Same as used when you called [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]]
+
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
 +
|}
  
;Returns
+
The addition of further texts would be subject to negotiation with the Mudlet Makers.
* true if successful, false if it didn't exist.
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local resumed = resumeNamedEventHandler("DemonVitals")
+
-- A replacement for the default function placed into LuaGlobal.lua to reproduce the previous behavior of the Mudlet application:
if resumed then
+
function doLogin()
  cecho("DemonVitals resumed!")
+
  if getCustomLoginTextId() ~= 1 then
else
+
    -- We need this particular option but it is not permitted for a script to change the setting, it can only check what it is
  cecho("DemonVitals doesn't exist, cannot resume it")
+
    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
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==sendCharacterName==
+
==sendCharacterName, PR #3952 open==
 
;sendCharacterName()
 
;sendCharacterName()
  
Line 363: Line 700:
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
 
{{note}} Not available yet. See https://github.com/Mudlet/Mudlet/pull/3952
  
 
+
==sendCharacterPassword, PR #3952 open==
==sendCharacterPassword==
 
 
;sendCharacterPassword()
 
;sendCharacterPassword()
  
Line 385: Line 721:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
+
==sendCustomLoginText, PR #3952 open ==
==sendCustomLoginText==
 
 
;sendCustomLoginText()
 
;sendCustomLoginText()
  
Line 398: Line 733:
 
Only one custom login text has been defined initially:
 
Only one custom login text has been defined initially:
 
{| class="wikitable"
 
{| class="wikitable"
|+ 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 420: Line 755:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==stopAllNamedEventHandlers==
+
=Mudlet Object Functions=
; stopAllNamedEventHandlers(handlerName)
+
:A collection of functions that manipulate Mudlet's scripting objects - triggers, aliases, and so forth.
  
:Stops all named event handlers and prevents them from firing any more. Information is retained and handlers can be resumed.
+
=Networking Functions=
 +
:A collection of functions for managing networking.
  
;See also: [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]], [[Manual:Lua_Functions#stopNamedEventHandler|stopNamedEventHandler()]], [[Manual:Lua_Functions#resumeNamedEventHandler|resumeNamedEventHandler()]]
+
=String Functions=
 +
:These functions are used to manipulate strings.
  
{{MudletVersion|4.14}}
+
=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.
  
;Example
+
=Text to Speech Functions=
<syntaxhighlight lang="lua">
+
: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.
stopAllNamedEventHandlers() -- emergency stop situation, most likely.
 
</syntaxhighlight>
 
  
==stopNamedEventHandler==
+
=UI Functions=
; success = stopNamedEventHandler(handlerName)
+
: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.
 
 
:Stops a named event handler with name handlerName and prevents it from firing any more. Information is stored so it can be resumed later if desired.
 
 
 
;See also: [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]], [[Manual:Lua_Functions#resumeNamedEventHandler|resumeNamedEventHandler()]]
 
  
{{MudletVersion|4.14}}
+
==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
+
; Parameters
* ''handlerName:''
+
* ''windowName:''
: The name of the handler to stop. Same as used when you called [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]]
+
: (optional) name of the window as a string to echo to. Use either ''main'' or omit for the main window, or the miniconsole's or user-window's name otherwise.
 +
* ''text:''
 +
: the text string to display.
 +
* ''{commands}:''
 +
: a table of lua code to do, in text strings or as functions (since Mudlet 4.11), i.e. <syntaxhighlight lang="lua" inline="">{[[send("hello")]], function() echo("hi!") end}</syntaxhighlight>.
 +
* ''{hints}:''
 +
: a table of strings which will be shown on the right-click menu (and popup if no {tool-tips} table is provided). If a particular position in both the commands and hints table are both the empty string ''""'' but there is something in the tool-tips table, no entry for that position will be made in the context menu but the tool-tip can still display something which can include images or text.
 +
* ''{tool-tips}:''
 +
: (optional) a table of possibly ''rich-text'' strings which will be shown on the popup if provided.
 +
* ''useCurrentFormatElseDefault:''
 +
: (optional) a boolean value for using either the current formatting options (color, underline, italic and other effects) if ''true'' or the link default (blue underline) if ''false'', if omitted the default format is used.
  
;Returns
+
{{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.
* true if successful, false if it didn't exist or was already stopped
 
  
 
;Example
 
;Example
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
local stopped = stopNamedEventHandler("DemonVitals")
+
-- Create some text as a clickable with a popup menu, a left click will ''send "sleep"'':
if stopped then
+
insertPopup("activities to do", {function() send "sleep" end, function() send "sit" end, function() send "stand" end}, {"sleep", "sit", "stand"})
  cecho("DemonVitals stopped!")
 
else
 
  cecho("DemonVitals doesn't exist or already stopped; either way it won't fire any more.")
 
end
 
</syntaxhighlight>
 
  
=Scripting Object Functions=
+
-- alternatively, put commands as text (in [[ and ]] to use quotation marks inside)
: A collection of functions that manipulate Mudlets scripting objects - triggers, aliases, and so forth.
+
insertPopup("activities to do", {[[send "sleep"]], [[send "sit"]], [[send "stand"]]}, {"sleep", "sit", "stand"})
  
==deleteAllNamedTimers==
+
-- one can also provide helpful information
; deleteAllNamedTimers(handlerName)
 
  
:Deletes all named timers and prevents them from firing any more. Information is deleted and cannot be retrieved.
+
-- todo: an example with rich-text in the tool-tips(s)
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
 
 
{{MudletVersion|4.14}}
 
 
;Example
 
<syntaxhighlight lang="lua">
 
deleteAllNamedTimers() -- emergency stop or debugging situation, most likely.
 
</syntaxhighlight>
 
 
==deleteNamedTimer==
 
; success = deleteNamedTimer(handlerName)
 
 
:Deletes a named timer with name handlerName and prevents it from firing any more. Information is deleted and cannot be retrieved.
 
 
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
 
 
{{MudletVersion|4.14}}
 
 
;Parameters
 
* ''handlerName:''
 
: The name of the handler to stop. Same as used when you called [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
 
 
;Returns
 
* true if successful, false if it didn't exist
 
;Example
 
<syntaxhighlight lang="lua">
 
local deleted = deletedNamedTimer("DemonVitals")
 
if deleted then
 
  cecho("DemonVitals deleted forever!!")
 
else
 
  cecho("DemonVitals doesn't exist and so could not be deleted.")
 
end
 
</syntaxhighlight>
 
 
==getNamedTimers==
 
; timers = getNamedTimers()
 
 
:Returns a list of all the named timers' names as a table.
 
 
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
 
 
{{MudletVersion|4.14}}
 
 
;Returns
 
* a table of handler names. { "DemonVitals", "DemonInv" } for example. {} if none are registered
 
 
;Example
 
<syntaxhighlight lang="lua">
 
  local timers = getNamedTimers()
 
  display(timers)
 
  -- {}
 
  registerNamedTimer("Test1", "testEvent", "testFunction")
 
  registerNamedTimer("Test2", "someOtherEvent", myHandlerFunction)
 
  timers = getNamedTimers()
 
  display(timers)
 
  -- { "Test1", "Test2" }
 
</syntaxhighlight>
 
 
==registerNamedTimer==
 
; success = registerNamedTimer(handlerName, eventName, functionReference, [repeating])
 
 
:Registers a named timer with name handlerName. Named timers are protected from duplication and can be stopped and resumed, unlike normal tempTimers.
 
 
;See also: [[Manual:Lua_Functions#tempTimer|tempTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]], [[Manual:Lua_Functions#resumeNamedTimer|resumeNamedTimer()]], [[Manual:Lua_Functions#deleteNamedTimer|deleteNamedTimer()]], [[Manual:Lua_Functions#registerNamedEventHandler|registerNamedEventHandler()]]
 
 
{{MudletVersion|4.14}}
 
 
;Parameters
 
* ''handlerName:''
 
: The name of the handler. Used to reference the handler in other functions and prevent duplicates. Recommended you use descriptive names, "hp" is likely to collide with something else, "DemonVitals" less so.
 
* ''eventName:''
 
: The name of the event the handler responds to. [[Manual:Event_Engine#Mudlet-raised_events|See here]] for a list of Mudlet-raised events.
 
* ''functionReference:''
 
: The function reference to run when the event comes in. Can be the name of a function, "handlerFuncion", or the lua function itself.
 
* ''repeating:''
 
: (optional) if true, the timer continue to fire until the stop it using [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
 
;Returns
 
* true if successful, otherwise errors.
 
 
;Example
 
<syntaxhighlight lang="lua">
 
-- establish a named timer called "Check balance" which runs balanceChecker() after 1 second
 
-- it is started automatically when registered, and fires only once despite being run twice
 
-- you wouldn't do this intentionally, but illustrates the duplicate protection
 
registerNamedTimer("Check Balance", 1, balanceChecker)
 
registerNamedTimer("Check Balance", 1, balanceChecker)
 
 
-- then the next time you want to make/use the same timer, you can shortcut it with
 
resumeNamedTimer("Check Balance")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==resumeNamedTimer==
+
=Discord Functions=
; success = resumeNamedTimer(handlerName)
+
: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]].
  
:Resumes a named timer with name handlerName and causes it to fire again. One time unless it was registered as repeating.
+
=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]].
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]]
+
=Supported Protocols=
  
{{MudletVersion|4.14}}
+
=Events=
 +
:New or revised events that Mudlet can raise to inform a profile about changes. See [[Manual:Event_Engine#Mudlet-raised_events|Mudlet-raised events]] for the existing ones.
  
;Parameters
+
===sysSettingChanged, PR #7476===
* ''handlerName:''
+
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.
: The name of the handler to resume. Same as used when you called [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
 
  
;Returns
+
Currently implemented sysSettingChanged events are;
* true if successful, false if it didn't exist. If the timer is waiting to fire it will be restarted at 0.
 
  
;Example
+
* "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 }
<syntaxhighlight lang="lua">
 
local resumed = resumeNamedTimer("DemonVitals")
 
if resumed then
 
  cecho("DemonVitals resumed!")
 
else
 
  cecho("DemonVitals doesn't exist, so cannot resume it.")
 
end
 
</syntaxhighlight>
 
  
==stopAllNamedTimers==
+
{{MudletVersion| ?.??}}
; stopAllNamedTimers(handlerName)
 
  
:Stops all named timers and prevents them from firing any more. Information is retained and timers can be resumed.
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/7476
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#stopNamedTimer|stopNamedTimer()]], [[Manual:Lua_Functions#resumeNamedTimer|resumeNamedTimer()]]
+
===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.14}}
+
{{MudletVersion| ?.??}}
  
;Example
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6615
<syntaxhighlight lang="lua">
 
stopAllNamedTimers() -- emergency stop situation, most likely.
 
</syntaxhighlight>
 
  
==stopNamedTimer==
+
===sysMapWindowMousePressEvent, PR #6962===
; success = stopNamedTimer(handlerName)
+
Raised when the mouse is left-clicked on the mapper window.
  
:Stops a named timer with name handlerName and prevents it from firing any more. Information is stored so it can be resumed later if desired.
+
{{MudletVersion| ?.??}}
  
;See also: [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]], [[Manual:Lua_Functions#resumeNamedTimer|resumeNamedTimer()]]
+
{{note}} pending, not yet available. See https://github.com/Mudlet/Mudlet/pull/6962
  
{{MudletVersion|4.14}}
+
===sysWindowOverflowEvent, PR #6872===
 +
Raised when the content in a mini-console/user window that has been set to be '''non-scrolling''' (see: [[#enableScrolling|enableScrolling(...)]] and [[#disableScrolling|disableScrolling(...)]]) overflows - i.e. fills the visible window and overflows off the bottom. Returns two additional arguments being the window's name as a string and the number of lines that have gone past that which can be shown on the current size of the window.
  
;Parameters
+
{{MudletVersion| ?.??}}
* ''handlerName:''
 
: The name of the handler to stop. Same as used when you called [[Manual:Lua_Functions#registerNamedTimer|registerNamedTimer()]]
 
  
;Returns
+
{{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).
* true if successful, false if it didn't exist or was already stopped
 
 
 
;Example
 
<syntaxhighlight lang="lua">
 
local stopped = stopNamedTimer("DemonVitals")
 
if stopped then
 
  cecho("DemonVitals stopped!")
 
else
 
  cecho("DemonVitals doesn't exist or already stopped; either way it won't fire any more.")
 
end
 
</syntaxhighlight>
 
 
 
=Networking Functions=
 
: A collection of functions for managing networking.
 
 
 
=String Functions=
 
: These functions are used to manipulate strings.
 
 
 
=Table Functions=
 
: These functions are used to manipulate tables. Through them you can add to tables, remove values, check if a value is present in the table, check the size of a table, and more.
 
 
 
=Text to Speech Functions=
 
: These functions are used to create sound from written words. Check out our [[Special:MyLanguage/Manual:Text-to-Speech|Text-To-Speech Manual]] for more detail on how this all works together.
 
 
 
=UI Functions=
 
: These functions are used to construct custom user GUIs. They deal mainly with miniconsole/label/gauge creation and manipulation as well as displaying or formatting information on the screen.
 

Latest revision as of 08:37, 27 December 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.

createMapLabel, merged #7598

labelID = createMapLabel(areaID, text, posX, posY, posZ, fgRed, fgGreen, fgBlue, bgRed, bgGreen, bgBlue[, zoom, fontSize, showOnTop, noScaling, fontName, foregroundTransparency, backgroundTransparency, temporary, outlineRed, outlineGreen, outlineBlue])
Creates a text label on the map at given coordinates, with the given background and foreground colors. It can go above or below the rooms, scale with zoom or stay a static size. From Mudlet 4.17.0 an additional parameter (assumed to be false if not given from then) makes the label NOT be saved in the map file which, if the image can be regenerated on future loading from a script can reduce the size of the saved map somewhat. It returns a label ID that you can use later for deleting it.
The coordinates 0,0 are in the middle of the map, and are in sync with the room coordinates - so using the x,y values of getRoomCoordinates() will place the label near that room.
See also: getMapLabel(), getMapLabels(), deleteMapLabel, createMapImageLabel()
Historical Version Note

Note Note: Some changes were done prior to 4.13 (which exactly? function existed before!) - see corresponding PR and update here!

Parameters
  • areaID:
Area ID where to put the label.
  • text:
The text to put into the label. To get a multiline text label add a '\n' between the lines.
  • posX, posY, posZ:
Position of the label in (floating point numbers) room coordinates.
  • fgRed, fgGreen, fgBlue:
Foreground color or text color of the label.
  • bgRed, bgGreen, bgBlue:
Background color of the label.
  • zoom:
(optional) Zoom factor of the label if noScaling is false. Higher zoom will give higher resolution of the text and smaller size of the label. Default is 30.0.
  • fontSize:
(optional, but needed if zoom is provided) Size of the font of the text. Default is 50.
  • showOnTop:
(optional) If true the label will be drawn on top of the rooms and if it is false the label will be drawn as a background, defaults to true if not given.
  • noScaling:
(optional) If true the label will have the same size when you zoom in and out in the mapper, If it is false the label will scale when you zoom the mapper, defaults to true if not given.
  • fontName:
(optional) font name to use.
  • foregroundTransparency
(optional) transparency of the text on the label, defaults to 255 (in range of 0 to 255) or fully opaque if not given.
  • backgroundTransparency
(optional) transparency of the label background itself, defaults to 50 (in range of 0 to 255) or significantly transparent if not given.
  • temporary
(optional) if true does not save the image that the label makes in map save files, defaults to false if not given, or for prior versions of Mudlet.
  • outlineRed, outlineGreen, outlineBlue
(optional) the outline colour of the displayed text
Example
-- the first 50 is some area id, the next three 0,0,0 are coordinates - middle of the area
-- 255,0,0 would be the foreground in RGB, 23,0,0 would be the background RGB
-- zoom is only relevant when when you're using a label of a static size, so we use 0
-- and we use a font size of 20 for our label, which is a small medium compared to the map
local labelid = createMapLabel( 50, "my map label", 0,0,0, 255,0,0, 23,0,0, 0,20)

-- to create a multi line text label add '\n' between lines
-- the position is placed somewhat to the northeast of the center of the map
-- this label will be scaled as you zoom the map.
local labelid = createMapLabel( 50, "1. Row One\n2. Row 2", .5,5.5,0, 255,0,0, 23,0,0, 30,50, true, false)

local x,y,z = getRoomCoordinates(getPlayerRoom())
createMapLabel(getRoomArea(getPlayerRoom()), "my map label", x,y,z, 255,0,0, 23,0,0, 0,20, false, true, "Ubuntu", 255, 100)

-- create a temporary, multiline label with purple text and a white outline lua createMapLabel(1, "This is a really long text\nwith multiple lines.", 0, 0, 0, 125, 0, 125, 0, 0, 0, 50, 48, true, false, "Noto Sans", 255, 0, true, 255, 255, 255)


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.

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.

Networking Functions

A collection of functions for managing networking.

String Functions

These functions are used to manipulate strings.

Table Functions

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

Text to Speech Functions

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

UI Functions

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

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